Reputation: 148524
I have an application which I declare as :
var app = angular.module('mg.app', ['mg.auth' , 'ui.router' ,'mg.calc' ]);
mg.auth
and mg.calc
are modules (my modules) which I inject as dependencies.
Code for mg.auth
:
angular.module('mg.auth', ['ui.router']);
angular.module('mg.auth').config(function ($stateProvider)
{
$stateProvider.state('signin', {
...
});
});
Code for mg.calc
:
angular.module('mg.calc', ['ui.router','ui.bootstrap']);
angular.module('mg.calc').config(function ($stateProvider)
{
$stateProvider.state('calc', {
...
});
}
In the HTML I have :
<a href ui-sref="calc">
When I click that link , it changes the state to calc
and I do see the desired result.
So where is the problem ?
Looking at my main module (ng.app
) , If I remove mg.calc
as a dependecy there is an error :
But I don't understand why do I need 'mg.calc' as a depency of mg.app
?
I mean , When JS engine sees the code for mg.calc
:
angular.module('mg.calc', ['ui.router','ui.bootstrap']);
angular.module('mg.calc').config(function ($stateProvider)
{
$stateProvider.state('calc', {
...
});
}
It knows that there is a new calc
state and should be able to transit to calc.
Question
Functionallity , why do mg.app
must set mg.calc
as a dependency ?
It is not that I use some code from mg.calc
in mg.app
Upvotes: 0
Views: 48
Reputation: 1273
it is because your angular app was bootstrapped with mg.app module, not mg.calc module, that's why you need to tell angular that you need mg.calc as well.
Upvotes: 1