我已经构建了下一个控制器:
.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
实现注射的正确方法是什么?
答案 0 :(得分:0)
我的第二次尝试:
.controller('chatCtrl', ['$scope','SharedState', '$route', '$routeParams', '$location', function($scope, SharedState, $route, $routeParams, $location)
用逗号作品。
感谢您的帮助! @Aprillion