H5 路由


<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body ng-app="routingDemoApp">
<h2>AngularJS 路由應用</h2>
        <ul>
            <li><a href="#/">首頁</a></li>
            <li><a href="#/computers">電腦</a></li>
            <li><a href="#/printers">打印機</a></li>
            <li><a href="#/blabla">其他</a></li>
        </ul>
        
        <!--路由配置的頁面會顯示在這個div中-->
        <div ng-view></div>
        
        <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
        <script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script>
        <script>
        // ['ngRoute'] 把路由功能依賴進來  
        var app = angular.module("routingDemoApp",['ngRoute'])
        //配置路由功能名字
        app.config(['$routeProvider', function($routeProvider){
        $routeProvider.when('/',{template: "我是主頁面"})
          .when('/computers',{template:'電腦分類頁面'})
          .when('/printers',{template:'打印機分類頁面'})
          .otherwise({redirectTo:'/'})
        }]);
       
        </script>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章