Angularjs 學習總結

瓜瓜東西發表於2018-07-15

1 angularjs 使用 ngRoute 路由外掛

<html>
<head>
    <meta charset="utf-8">
    <title>AngularJS 路由例項 - 菜鳥教程</title>
</head>
<body  ng-app="testdemo">
<ul>
    <li><a href="#/">aaa</a></li>
    <li><a  href="#/bbb">bbb</a></li>
    <li><a  href="#/ccc">ccc</a></li>
</ul>
<div ng-view></div>
<script src="https://cdn.bootcss.com/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>
    angular.module("testdemo",['ngRoute'])
            .config(['$routeProvider',function($routeProvider){
                $routeProvider.when("/",{template:"abc"})
                        .when("/bbb",{template:"bbb"})
                        .otherwise({template:"ccc"});
            }]);
</script>
</body>
</html>