我正在尝试restangular
用作 rails rest api 的适配器,但我无法使其正常工作。我已经下载了最新版本并将文件放在 vendor/assets/javascripts 文件夹中。但是一旦我尝试加载应用程序,我就会收到以下错误:
Error: Unknown provider: RestangularProvider <- Restangular
at Error (<anonymous>)
at http://0.0.0.0:3000/assets/angular.js?body=1:2706:19
at Object.getService [as get] (http://0.0.0.0:3000/assets/angular.js?body=1:2832:39)
at http://0.0.0.0:3000/assets/angular.js?body=1:2711:45
at getService (http://0.0.0.0:3000/assets/angular.js?body=1:2832:39)
at invoke (http://0.0.0.0:3000/assets/angular.js?body=1:2850:13)
at Object.instantiate (http://0.0.0.0:3000/assets/angular.js?body=1:2882:23)
at http://0.0.0.0:3000/assets/angular.js?body=1:4771:24
at http://0.0.0.0:3000/assets/angular.js?body=1:4350:17
at forEach (http://0.0.0.0:3000/assets/angular.js?body=1:161:20)
这是我的 application.js 文件
//= require jquery
//= require bootstrap
//= require suggest.min
//= require angular
//= require underscore
//= require restangular
//= require angular-strap.min
//= require angular-cookies
//= require angular-resource
//= require angular/index
应用程序初始化如下:
angular.module('angularApp', [
'ngCookies',
'restangular'
]);
angular.module('angularApp.services', [
'ngResource',
'sessionService',
'courseService'
]);
angular.module('angularApp.resources', [
'ngResource'
]);
angular.module('angularApp.directives', []);
angular.module('angularApp.filters', []);
angular.module('angularApp.controllers', []);
var App = angular.module('angularApp', [
'angularApp.resources',
'angularApp.services',
'angularApp.directives',
'angularApp.filters',
'angularApp.controllers',
'$strap.directives'
]);
还有一个控制器试图使用restangular但没有成功
angular.module('angularApp.controllers').controller('CourseListCtrl', [
'$scope', '$location', 'Restangular',
function($scope, $location, Restangular) {"use strict";
$scope.courses = Restangular.all('courses')
}]);
我究竟做错了什么?似乎我已经完成了restangular指南中描述的所有内容,但仍然不明白它不起作用的原因。