angularjs从1.4.8发生了什么变化,这个路由不再起作用了?

时间:2017-04-17 16:54:41

标签: angularjs angularjs-routing

我正在尝试了解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>

我已经检查了更改日志,但一无所获。

0 个答案:

没有答案