我已经建立了下一个控制器:
.controller('myCtrl', function($scope, $route, $routeParams, $location)
现在我想注入一种叫做SharedState的东西。试着:
.controller('chatCtrl' ['SharedState', function($scope, $route, $routeParams, $location, SharedState)
或者:
.controller('chatCtrl' ['$scope','SharedState', '$route', '$routeParams', '$location', function($scope, SharedState, $route, $routeParams, $location)
都返回错误:
Error: [ng:areq] http://errors.angularjs.org/1.2.27/ng/areq?p0=myCtrl&p1=not%20aNaNunction%2C%20got%20undefined
注射的正确方法是什么?
我的第二次尝试:
.controller('chatCtrl', ['$scope','SharedState', '$route', '$routeParams', '$location', function($scope, SharedState, $route, $routeParams, $location)
与逗号作品。
感谢您的帮助!@Aprillion
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句