问题描述
我试图用 restangular
作为轨道REST API适配器,但我不能让它正常工作。我已经下载了最新版本,并在文件中的供应商/资产/ JavaScript的文件夹中。但一旦我尝试加载应用程序,我得到以下错误:
I'm trying to use restangular
as an adapter for rails rest api, but i can't make it work properly. I've downloaded the latest version and put the file in vendor/assets/javascripts folder. But once i try to load the app i get the following error:
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文件
Here is my application.js file
//= 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
该应用程序初始化如下:
The app is initialized as follows:
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没有任何成功控制器
There is also a controller which tempts to use restangular without any success
angular.module('angularApp.controllers').controller('CourseListCtrl', [
'$scope', '$location', 'Restangular',
function($scope, $location, Restangular) {"use strict";
$scope.courses = Restangular.all('courses')
}]);
我究竟做错了什么?看来我已经做了restangular指南中所描述的一切,但还是不明白为什么它不工作的原因。
What am i doing wrong? It seems i've done everything described in the restangular guide, but still don't understand the reason why it's not working.
推荐答案
按我的意见,你定义模块的两倍,它覆盖了第二次你的 restangular
包容性。
As per my comment, you're defining the module twice, the second time it overrides your restangular
inclusion.
这篇关于Restangular:错误:未知提供商:RestangularProvider&LT; - Restangular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!