[英]Angular.js - can't inject external module
I'm trying to make the simplest possible website setting, where I have an Angular.js app with single module depending on one external module (for example Restangular). 我试图做一个最简单的网站设置,在这里我有一个Angular.js应用,该应用具有一个模块,具体取决于一个外部模块(例如Restangular)。
I don't know why, but I can not get it working. 我不知道为什么,但是我无法正常工作。 I'm getting get this kind of error:
我得到这种错误:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.17/$injector/unpr?p0=restangularProvider%20%3C-%20restangular
Actually, it doesn't matter that it's restangular - I've tried it with other modules and the result was analogical. 实际上,它不是矩形的-我已经在其他模块上尝试过,结果是类比。
I have created a plunker that shows my problem: http://plnkr.co/edit/3ZUoDYtd4sVTT7nLpURi?p=preview 我已经创建了一个显示问题的插件: http ://plnkr.co/edit/3ZUoDYtd4sVTT7nLpURi?p=preview
But there is not that much code - I will paste it here too. 但是没有太多代码-我也将其粘贴到这里。
In my index.html file I include angular.js, lodash.js (required by restangular), restangular.js and my application's script.js files with tags. 在我的index.html文件中,我包括angular.js,lodash.js(restangular要求),restangular.js和带有标签的应用程序的script.js文件。
This is the body of my html: 这是我的html的正文:
<body ng-app="example" ng-controller="AppCtrl">
<p>Take a look into console... Restangular can not get injected. What am I doing wrong?</p>
</body>
And this is the content of script.js: 这是script.js的内容:
var app = angular.module( 'example', ['restangular'])
app.controller('AppCtrl', ['$scope', 'restangular', function($scope, Restangular) {
console.log(Restangular);
}]);
As a note - in the console I can do this: 注意-在控制台中,我可以这样做:
angular.module('restangular')
but, this does not work: 但是,这不起作用:
angular.injector(["ng"]).get('restangular')
It seems that I'm missing something basic about Angular.js. 似乎我缺少有关Angular.js的基本知识。 Help will be appreciated...
帮助将不胜感激...
Could it be this? 可能是这个吗?
app.controller('AppCtrl', ['$scope', 'Restangular', function($scope, Restangular) {
Restangular hast to be written with a capital R You wrote 矩形必须用大写R书写
app.controller('AppCtrl', ['$scope', 'restangular', function($scope, Restangular) {
At least now I see in the console 至少现在我在控制台中看到了
URL visited /edit/3ZUoDYtd4sVTT7nLpURi
editor-0.7.30.js
Object { configuration={...}, requestParams={...}, defaultHeaders={...}, more...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.