I'm a little confused about how modules load in angular. Take for example the following code:
var app = angular.module("app", [ "app.widgets", "app.core"]);
var core = angular.module("app.core", []);
core.factory("foo", function(){
return {
ping: function(){
return "pong";
}
}
});
var widgets = angular.module("app.widgets", []);
widgets.controller("WidgetController", function($scope, foo){
$scope.items = [1,2,3,foo.ping()];
});
<body ng-app="app">
<ul ng-controller="WidgetController">
<li ng-repeat="item in items">
{{item}}
</li>
</ul>
</body>
I'm confused as to how my "app.widgets" module has access to the "app.core" module even though it wasn't declared as a dependency.
It seems to be picking up the dependency because both "app.widgets" and "app.core" are declared in a third module--- which is very convenient. But it doesn't seem very intuitive to me.
So I guess my question is "will two modules 'know' about each other if they are declared in a third module?". And is that documented behavior?