I'm creating my first module and i don't know how to inject a simple object factory.
angular.module('mymodule', [])
.factory('mymodulefactory', function () {
return { a:1, b:2 };
});
This is my app:
angular.module('myapp', ['mymodule'])
.controller('myController', function($scope, mymodule){ //error
console.log(mymodule) //undefined
console.log(mymodulefactory) //undefined
});
You can inject like this:
.controller('myController', function($scope, mymodulefactory) {
...
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.