大佬教程收集整理的这篇文章主要介绍了angular config路由配置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html> <html lang="en"> <head> <Meta charset="UTF-8"> <Meta name="viewport" content="width=device-width,initial-scale=1.0"> <Meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <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> <body ng-app="routIngDemoApp"> <h2>angular路由应用</h2> <ul> <li><a href="#/">首页</a></li> <li><a href="#/computer">电脑</a></li> <li><a href="#/print">打印机</a></li> <li><a href="#/blabla">其他</a></li> </ul> <div ng-view></div> <script> var app = angular.module('routIngDemoApp',['ngRoute']);//成功注册一个模版routIngDemoApp,并且依赖注入ngRoute //在config配置文件中,配置$routeProvider,用来定义路由规则 //angularJS模块中的config函数用于配置路由规则,通过使用COnfigAPI,我们请求把$routerProvider注入到我们的配置函数, //并使用routeProvider.when 来定义我们的路由规则 //template:string,字符串被添加到ng-view中,templateUrl:string,URL地址中的文件被添加到ng-view中 app.config(['$routeProvider'],function($routeProvider){ $routeProvider.when('/',{template:'首页'}) .when('/computer',{template:'电脑'}) .when('/print',{template:'打印机'}) .when('/regist',{tempateUrl:'/view/regist.html'}) .otherwise({redirectTo:'/'}); }); </script> </body> </html>@H_674_1@大佬总结
以上是大佬教程为你收集整理的angular config路由配置全部内容,希望文章能够帮你解决angular config路由配置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。