AngularJs ui router
2018-01-31 00:09
387 查看
AngularJs ui router是一个用于路由的第三方库,比AngularJs本身的路由更强大和易用
创建一个SPA页面
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="../lib/bootstrap.min.css"> <script src="../lib/angular.min.js"></script> <script src="../lib/angular-ui-router.js"></script> </head> <body> <div ng-app="helloworld"> <a ui-sref="hello">Hello</a> <a ui-sref="about">About</a> <div ui-view=""></div> </div> <script> var a = angular.module('helloworld',['ui.router']); //使用config将$stateProvider和$urlRouterProvider依赖注入 a.config(function ($stateProvider,$urlRouterProvider) { var helloState = { name:'hello', url:'/hello', template:'<h1>这是hello页面</h1>' }; var aboutState = { name:'about', url: '/about', template:'<h1>这是about页面</h1>' }; var otherState = { name:'other', url:'/other', template:'<h2>出错啦</h2>' }; //设置当没有找到匹配的url时的跳转 $urlRouterProvider.otherwise("/other"); $stateProvider.state(helloState); $stateProvider.state(aboutState); $stateProvider.state(otherState); }) </script> </body> </html>
相关文章推荐
- angularjs ui-router路由移除#解决方案
- AngularJS + ui-router + RequireJS异步加载注册controller/directive/filter/service
- AngularJS ui-router (嵌套路由)
- A Better $state.reload for the AngularJS UI-Router
- angularjs+ui-router+requirejs+angularAMD+SSM项目实战
- AngularJS ui-router (嵌套路由)实例
- [转]AngularJS ui-router (嵌套路由)
- AngularJs ui-router 路由的介绍
- AngularJS ui-router 用resolve、service预先加载数据的正确写法
- AngularJS ui-router (嵌套路由)
- angular+ui-router+requirejs整合demo
- AngularJS Routing Using UI-Router
- AngularJs ui-router 路由的简单介绍
- angularjs+bootstrap+SpringMVC+Spring+mybatis+maven--ui.router路由一
- angularjs ui-router
- AngularJS ui-router (嵌套路由)
- The basics of using ui-router with AngularJS
- angularJS+ui-router+requireJS异步加载controller、directive、filter
- AngularJS ui-router (嵌套路由)
- 详解AngularJs ui-router 路由的简单介绍