我有限定的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