AngularJS angular-route路由应用
引用文件:
angular.min.js
angular-route.min.js
html代码:
<body ng-app='routingDemoApp'>
<h2>AngularJS angular-route路由应用</h2>
<ul>
<li><a href="#!/">首页</a></li>
<li><a href="#!/php">php</a></li>
<li><a href="#!/Java">Java</a></li>
<li><a href="#!/angular">angular</a></li>
<li><a href="#!/vue">vue</a></li>
</ul>
<div ng-view></div>
</body>
JavaScript代码:
<script>
angular.module('routingDemoApp',['ngRoute'])
.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/',{template:'网站首页'})
.when('/php',{template:'php项目'})
.when('/Java',{template:'Java项目'})
.when('/angular',{template:'angular项目'})
.when('/vue',{template:'vue项目'})
.otherwise({redirectTo:'/'});
}]);
</script>