In the same way as $scope is independent of each controller. Exists the way to create a module independent for each controller?
angular.module('mymodule', []).service('mymodule', function () {});
angular.module('myapp', ['mymodule'])
.controller('myController2', function($scope, mymodule) {
console.log(
$scope.hello, // undefined
mymodule.hello, // "world"
s === $scope, // false
m === mymodule // true
);
})
.controller('myController', function($scope, mymodule) {
s = $scope;
m = mymodule;
$scope.hello = "world";
mymodule.hello = "world";
});
I tried with factory's and providers.
Aucun commentaire:
Enregistrer un commentaire