fourth fourth - 1 year ago 91
Node.js Question

about module in the angular

I am new in this field and reading about one project code. Here are two file.
In the first file:

'use strict';
angular.module('app.dashboard', ['firebase']);

In the second file, similiar code appears again

I see many code write like
var app=angular.module(...)
, if you write in way of first file, how could you use the module again? and why you write it in this way?

I also want to know why you write the first file here, why don't you put all things in the second file.


Answer Source

When you define your module in angular, you have to define an array as second parameter with the list of modules your module depend on (or an empty array if is not depending on anything).

When you use your module in angular, you skip this second parameter.

These are the two cases in your code.

You could put everything in same file, but it is considered a general good practice to keep individual files for different controllers/services/directives (or even the definition of the module).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download