Angularjs 获取:错误:[$injector:unpr]未知提供程序:Chrome上的错误
我是AngularJS的新手,在Chrome上运行AngularJS教程7时遇到了问题。在Chrome上,我在控制台上遇到以下错误:Angularjs 获取:错误:[$injector:unpr]未知提供程序:Chrome上的错误,angularjs,google-chrome,angular-routing,Angularjs,Google Chrome,Angular Routing,我是AngularJS的新手,在Chrome上运行AngularJS教程7时遇到了问题。在Chrome上,我在控制台上遇到以下错误: angular.js:10126 Error: [$injector:unpr] Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective http://errors.angularjs.org/1.2.28/$injec
angular.js:10126 Error: [$injector:unpr] Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective
http://errors.angularjs.org/1.2.28/$injector/unpr?p0=%24templateRequestProvider%20%3C-%20%24templateRequest%20%3C-%20%24route%20%3C-%20ngViewDirective
at VALIDITY_STATE_PROPERTY (angular.js:78)
at angular.js:3801
at Object.getService [as get] (angular.js:3929)
at angular.js:3806
at getService (angular.js:3929)
at Object.invoke (angular.js:3956)
at angular.js:3807
at getService (angular.js:3929)
at Object.invoke (angular.js:3956)
at angular.js:5716
controllers.js
'use strict';
/* App Module */
var phonecatApp = angular.module('phonecatApp', [
'ngRoute',
'phonecatControllers'
]);
phonecatApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/phones/:phoneId', {
templateUrl: 'partials/phone-detail.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}]);
'use strict';
/* Controllers */
var phonecatControllers = angular.module('phonecatControllers', []);
phonecatControllers.controller('PhoneListCtrl', ['$scope', '$http',
function($scope, $http) {
$http.get('phones/phones.json').success(function(data) {
$scope.phones = data;
});
$scope.orderProp = 'age';
}]);
phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams',
function($scope, $routeParams) {
$scope.phoneId = $routeParams.phoneId;
}]);
bower.json
{
"name": "angular-phonecat",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-phonecat",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.3.x",
"angular-mocks": "1.3.x",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
"angular-route": "1.3.x"
}
}
目前,我正在学习NRO7教程,其中包括路由。教程1-6没有使用路由,页面在Chrome上运行良好。因此,问题可能与路由有关
任何帮助都将不胜感激。非常感谢。看来,它为什么不在Chrome上运行的问题不仅仅与浏览器有关;这也是Node.js的一个问题。本教程指示使用Node.js作为教程的Web服务器,在教程nro 7之前,它一直运行良好,部分视图使用了路由。现在看来,由于某种原因,当Node.js被用作Web服务器时,路由在Chrome上不起作用。当我尝试在Web服务器上使用Apache而不是Node.js时,我发现了这一点。在Apache上托管教程Web项目后,路由开始在Chrome上正常运行。因此,问题似乎与Chrome和Node.js有关 我的Node.js版本是v0.10.33(因此它不是可用的最新版本) 下面是网页托管在Apache上时Chrome的屏幕截图
您使用的是angular.js的哪个版本?您使用的是angular版本..???@pankajparkar我检查了它的AngularJS v1.3.10,这是我在bower_组件中的angular文件中找到的subfolders@squiroid我检查了它的AngularJSV1.3.10,这就是我在bower_组件中的AngularJS文件中发现的subfolders@pankajparkar我通过指定angular version 1.3.3和angular route 1.3升级了第一个更改bower.json文件,但它不起作用。我的意思是,我在运行时出错:npm install命令-->npm ERR!棱角的-phonecat@0.0.0安装后:
bower安装
。。npm错误!在角度上失败了-phonecat@0.0.0安装后脚本。npm错误!这很可能是angular phonecat软件包的问题,。。顺便问一下,我用Bower正确地更新了这些角度版本了吗?无论如何,我认为只要路由在IE或Opera上运行,我就会管理它。然而,测试在Chrome上运行。谢谢你的帮助。