未知提供商:$ templateRequestProvider&LT; - $ templateRequest&LT; - $航线&LT; - ngViewDirective [英] Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective
问题描述
我刚开始用angular.js我看着一些老TUTS。其中,NG-路线是不存在依赖关系,所以我改变了我的code,并添加&LT; SCRIPT SRC =JS /供应商/角route.js&GT;&LT; / SCRIPT&GT;
在HTML中,但我得到了同样的错误未知提供商:$ templateRequestProvider&LT; - $ templateRequest&LT; - $航线&LT; - ngViewDirective
HTML
&LT;!DOCTYPE HTML&GT;
&LT; HTML类=无JSLANG =ENGT&;
&LT; HEAD&GT;
&LT;间的charset =UTF-8/&GT;
&LT; META NAME =视口CONTENT =WIDTH =设备宽度,初始规模= 1.0/&GT;
&LT;标题&GT;测试与LT; /标题&GT;
&LT;链接rel =stylesheet属性HREF =CSS / foundation.css/&GT;
&LT;链接rel =stylesheet属性HREF =CSS /的main.css/&GT;
&LT;脚本SRC =JS /供应商/ modernizr.js&GT;&LT; / SCRIPT&GT;
&LT;脚本SRC =JS /供应商/ angular.js&GT;&LT; / SCRIPT&GT;
&LT;脚本SRC =JS /供应商/角route.js&GT;&LT; / SCRIPT&GT;
&LT;脚本SRC =JS /供应商/ main.js&GT;&LT; / SCRIPT&GT;
&LT; /头&GT;
&LT;身体GT;
&LT; DIV NG-应用=应用程序&GT;
&LT; NG-视图&gt;&LT; / NG-视图&gt;
&LT; / DIV&GT;&LT; /身体GT;
&LT; / HTML&GT;
JS:
VAR应用= angular.module(应用程序,['ngRoute']);的app.config(['$ routeProvider',函数($ routeProvider){
$ routeProvider.when(/,{
templateUrl:模板/ /home.html的,
控制器:AppCtrl
}
);
}]);app.controller(AppCtrl功能($范围){
$ scope.model = {
消息:这是我的应用程序!
}
});
home.html的:
&LT; H1&GT; {{model.message}}&LT; / H1&GT;
采用了棱角分明路由1.3.14和1.2.14角时,我遇到了这个问题,您需要升级的角度通过角路由所需的版本。在这里,角路线1.3.14的凉亭,它需要角度1.3.14。
{
名:角路线,
版本:1.3.14
主:./angular-route.js
忽视: [],
依赖:{
角度:1.3.14
},
主页:https://github.com/angular/bower-angular-route
_release:1.3.14,
_解析度: {
类型:版本,
标签:v1.3.14
承诺:a405245afdb0f1eac5aad4d8ddc555ed557b3345
},
_source:混帐://github.com/angular/bower-angular-route.git
_target:1.3.14,
_originalSource:角路线
}
I'm just starting with angular.js and I watched some older tuts. where ng-route was not a dependency, so I have changed my code and added <script src="js/vendor/angular-route.js"></script>
in html, but I'm getting the same error Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective
HTML:
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>test</title>
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/main.css" />
<script src="js/vendor/modernizr.js"></script>
<script src="js/vendor/angular.js"></script>
<script src="js/vendor/angular-route.js"></script>
<script src="js/vendor/main.js"></script>
</head>
<body>
<div ng-app="app">
<ng-view></ng-view>
</div>
</body>
</html>
JS:
var app = angular.module("app", ['ngRoute']);
app.config(['$routeProvider', function($routeProvider){
$routeProvider.when("/",{
templateUrl: "templates/home.html",
controller: "AppCtrl"
}
);
}]);
app.controller("AppCtrl", function($scope){
$scope.model = {
message: "This is my app!!!"
}
});
home.html:
<h1>{{model.message}}</h1>
I met the issue when using angular-route 1.3.14 and angular 1.2.14 , You need to upgrade angular to version required by angular-route . Here the bower of angular-route 1.3.14 , it require angular 1.3.14.
{
"name": "angular-route",
"version": "1.3.14",
"main": "./angular-route.js",
"ignore": [],
"dependencies": {
"angular": "1.3.14"
},
"homepage": "https://github.com/angular/bower-angular-route",
"_release": "1.3.14",
"_resolution": {
"type": "version",
"tag": "v1.3.14",
"commit": "a405245afdb0f1eac5aad4d8ddc555ed557b3345"
},
"_source": "git://github.com/angular/bower-angular-route.git",
"_target": "1.3.14",
"_originalSource": "angular-route"
}
这篇关于未知提供商:$ templateRequestProvider&LT; - $ templateRequest&LT; - $航线&LT; - ngViewDirective的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!