繁体   English   中英

Angular仍然无法识别$ resource

[英]Angular is still not recognising $resource

我在应用程序的模块中注入ngResource:

angular.module('confusionApp', ['ui.router', 'ngResource'])

,然后在我的服务中注入$ resource依赖项:

angular.module('confusionApp')
    .constant('baseURL', 'http://localhost:3000/')
    .service('menuFactory', ['$resource', 'baseURL', function($resource, baseURL) {

我还在index.html文件中包含了脚本:

<script src="../bower_components/angular/angular.js"></script>
    <script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script>
    <script src="../bower_components/angular-resource/angular-resource.js"></script>
    <script src="scripts/app.js"></script>
    <script src="scripts/controllers.js"></script>
    <script src="scripts/services.js"></script>

我在机器上运行一个json服务器,并且每当$ resource请求数据时,浏览器的js控制台都无法识别$ resource并显示此错误:

错误:[$ injector:unpr]未知提供程序:$ resourceProvider <-$ resource <-menuFactory

请帮助或指向可以帮助的地方!!

更新资料

我的bower.json依赖项:

"dependencies": {
"bootstrap": "~3.3.5",
"font-awesome": "~4.4.0",
"angular": "1.4.x",
"angular-route": "1.4.x",
"angular-resource": "1.4.x",
"angular-ui-router": "~0.2.17"
}

事实证明,这是角度和角度资源版本之间的冲突。 我不知道它是如何安装的,因为我已经通过bower安装了它,尽管我确实在bower.json中明确提到了它的版本,但是在安装时并没有让bower命令工具保存它。 我必须从bower_components中删除angular-resource,还必须从bower.json中删除依赖项,并使用-S标志重新安装angular-resource。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM