我将这个角度应用程序和控制器模块定义如下:
var myTasks = angular.module('myTasks', [
'ngRoute',
'myTasksControllers'
]);
var myTasksControllers = angular.module('myTasksControllers',[]);
我也有:
<script src="js/lib/angular.min.js"></script>
<script src="js/lib/angular-route.min.js"></script>
<script src="js/lib/lodash.min.js"></script>
<script src="js/lib/restangular.min.js"></script>
<script src="js/app.js"></script>
我正试图将rectangular
注入我的控制器,如下所示:
myTasksControllers.controller('ProjectsController', ['$scope','rectangular',
function ($scope, Rectangular) {
...
...
}
]);
但它一直告诉模块没有定义或什么。确切地说:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.3/$injector/unpr?p0=rectangularProvider%20%3C-%20rectangular
at Error (<anonymous>)
矩形:https://github.com/mgonto/restangular#how-do-i-add-this-to-my-project
答案 0 :(得分:4)
您必须先将restangular
模块注入myTasks
模块。像这样:
var myTasks = angular.module('myTasks', [
'restangular',
'ngRoute',
'myTasksControllers'
]);
然而,你必须将Restangular
注入你的控制器:
myTasksControllers.controller('ProjectsController', ['$scope','Restangular',
function ($scope, Restangular) {
...
...
}
]);
P.S。:请注意,您在问题中将其拼写为“矩形”:)