我正在尝试了解AngularJS路由,并获得此代码进行研究。它正在使用版本1.4.8,但是当我更新到1.6.x时停止工作。
<!DOCTYPE html>
<html>
<!-- DOESN'T WORK -->
<script src="https://code.angularjs.org/snapshot/angular.min.js"></script>
<script src="https://code.angularjs.org/snapshot/angular-route.js"></script>
<!-- WORKS -->
<!--
<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>
-->
<body ng-app="myApp">
<p><a href="#/">Main</a></p>
<a href="#red">Red</a>
<a href="#green">Green</a>
<a href="#blue">Blue</a>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm"
})
.when("/red", {
templateUrl : "red.htm"
})
.when("/green", {
templateUrl : "green.htm"
})
.when("/blue", {
templateUrl : "blue.htm"
});
});
</script>
<p>Click on the links to navigate to "red.htm", "green.htm", "blue.htm", or back to "main.htm"</p>
</body>
</html>
我已经检查了更改日志,但一无所获。