ng-view指令不起作用。我所看到的只是" Page"标题。有什么问题?
https://jsfiddle.net/dsgfdyp1/3/
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<script type="text/javascript" src="./scripts/app.js"></script>
页
<div ng-view> </div>
var myApp = angular.module(&#39; myApp&#39;,[&#39; ngRoute&#39;]);
app.config(&#39; routeProvider&#39;,function($ routeProvider){
$routeProvider
.when("/", {templateUrl : "/home"});
});
答案 0 :(得分:1)
从routeProvider
myApp.config('routeProvider', function($routeProvider)
如下所示
var myApp = angular.module("myApp", ["ngRoute"]);
myApp.config(function($routeProvider) {
$routeProvider
.when("/", {templateUrl : "/templates/main.htm"});
});
基于$ inject的解决方案
myApp.config(routerConfig);
routerConfig.$inject =["$routeProvider"];
function routerConfig($routeProvider){
$routeProvider
.when("/", {templateUrl : "/templates/main.htm"});
}