admin管理员组文章数量:1432759
I am using following link for using requirejs with angularjs .github/tree/master/examples/angularjs-requirejs-2
how can i use service function which is defined in js\services\version.js
i have following code in services.
services.factory('Phone', ['$resource',
function($resource){
console.log("factory");
}]);
i want to call this factory function in controller. how to do that?
I am using following link for using requirejs with angularjs https://github./StarterSquad/startersquad.github./tree/master/examples/angularjs-requirejs-2
how can i use service function which is defined in js\services\version.js
i have following code in services.
services.factory('Phone', ['$resource',
function($resource){
console.log("factory");
}]);
i want to call this factory function in controller. how to do that?
Share Improve this question asked Apr 21, 2014 at 11:55 PriyaPriya 1,4814 gold badges32 silver badges56 bronze badges2 Answers
Reset to default 4Just add the factory in your controller.
app.controller('myController', function($scope, Phone){
});
First you have to register your service in " angular.module(); "
app.controller('myController',['Phone','$scope',function(Phone,$scope){
//your code here
}]);
本文标签: javascriptAngularJS call factory from controllerStack Overflow
版权声明:本文标题:javascript - AngularJS: call factory from controller - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745443915a2658573.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论