我有限定的MyResource服务是这样的:角控制器内联注释语法
angular.module('resourceApp')
.factory('MyResource', ['$resource', function($resource) {
return $resource('/data');
}]);
然后我有一个使用MyResource作为扶养控制器:
angular.module('resourceApp')
.controller('MainCtrl', ['MyResource', function($scope, MyResource) {
$scope.data = MyResource.get(); // <-- this is where the error occurs
}]);
当我定义扶养等上面,使用行内数组注释,我在标注了注释的行处出现“MyResource is undefined”错误。
但是,如果我改变语法隐注释:
angular.module('resourceApp')
.controller('MainCtrl', function($scope, MyResource) {
$scope.data = MyResource.get();
});
我神奇地把事情的工作!
现在的问题是:第一个出了什么问题?我可以离开隐式注释,但文档说它不能在缩小之后存活。
是的!我尝试了包括'$ scope',但是放了_after_'MyService'!这就是为什么它不起作用。 – 2014-11-22 12:12:28