Camila Waz 发布于
2018-08-16 14:46:07

AngularJS angular-route路由应用

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>
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2018-08-16/104.html
最后生成于 2020-08-31 16:49:43