[email protected]一个简单的UI-Router路由demo

1、index.html:

<!DOCTYPE HTML>
<html ng-app="routerApp">
<head>
    <title>UI-Router路由demo</title>
    <meta charset="utf-8">    
    <link rel="stylesheet" href="../framework/bootstrap-3.0.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="../framework/ng-grid-2.0.12/ng-grid.css">
    <script src="../framework/jquery-1.9.1.js"></script>
    <script src="../framework/angular-1.3.0.14/angular.js"></script>
    <script src="../framework/angular-1.3.0.14/angular-animate.min.js"></script>
    <script src="../framework/angular-ui-router.js"></script>

<script src="../framework/ui-bootstrap-tpls-0.11.0.js"></script>

<script src="../framework/ng-grid-2.0.12/ng-grid.debug.js"></script>
    <link rel="stylesheet" href="css/app.css">
    <script src="js/app.js"></script>
    <script src="js/animations.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/filters.js"></script>
    <script src="js/services.js"></script>

</head>
<body>
<div class="container">
<div>aaaaaaaaaaaaaaa</div>
    <div ui-view></div><!--子模板页都会自动加载到这个ui-view层中-->
<div>bbbbbbbbbbbbbbb</div>
</div>
</body>
</html>

2、app.js:

var myModule = angular.module("routerApp",[‘ui.router‘]);

myModule.config([‘$stateProvider‘,‘$urlRouterProvider‘,function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise(‘/index‘);//默认的触发路径是/index
    $stateProvider
        .state(‘index‘,{//index是状态名
            url:‘/index‘,//触发模板加载的路径
            templateUrl:‘tpls/test.html‘
        })
        .state(‘addbook‘,{
            url:‘/addbook‘,
            templateUrl:‘tpls/test1.html‘//没有嵌套,直接在父页面的ui-view=‘‘处加载模板页
        })
        .state(‘bookdetail‘,{
            url:‘/bookdetail‘,
            templateUrl:‘tpls/test2.html‘
        });
}]);

注意一点:在服务器端运行该脚本的时候,一定要在url路径前加上/#号,写成这样才有效:http://127.0.0.1/angularjs/uiRouter/#/addbook

时间: 2024-08-25 10:21:20

[email protected]一个简单的UI-Router路由demo的相关文章

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(六)

无书面许可请勿转载 高级playbook Finding files with variables All modules can take variables as part of their arguments by dereferencing them with {{ and }} . You can use this to load a particular file based on a variable. For example, you might want to select a

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(七)

如无书面授权,请勿转载 Larger Projects Until now, we have been looking at single plays in one playbook file. This approach will work for simple infrastructures, or when using Ansible as a simple deployment mechanism. However, if you have a large and complicated

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(四)

无书面许可请勿转载 由于第三章内容较长,我将分做几个部分来翻译. Advanced Playbooks So far the playbooks that we have looked at are simple and just run a number of modules in order. Ansible allows much more control over the execution of your playbook. Using the following techniques

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(九)

如无书面授权,请勿转载 第四章 大型项目中Ansible的使用 New features in 1.3 There are two features in Ansible 1.3 that were alluded to previously in the chapter. The first feature is the metadata roles. They allow you to specify that your role depends on other roles. For ex

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(十)

无书面许可,请勿转载 Custom Modules Until now we have been working solely with the tools provided to us by Ansible. This does afford us a lot of power, and make many things possible. However, if you have something particularly complex or if you find yourself u

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(十一)

无书面授权,请勿转载 第五章 自定义模块 Using a module Now that we have written our very first module for Ansible, we should give it a go in a playbook. Ansible looks at several places for its modules: first it looks at the place specified in the library key in its con

[安卓基础] 005.创建一个简单的UI

*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } a { color: #4183C4; text-decoration: none; } a.absent { color: #cc0000; } a.anchor { display: block; padding-left: 30px; margin-left: -30px; cursor: poin

Android学习路线(四)构建一个简单的UI

Android应用的图形化用户界面的构建使用的是View 和 ViewGroup 对象的层次嵌套. View 对象通常是UI部件,例如 buttons 或者 text fields ,而 ViewGroup 是用来定义它的子布局如何排布的容器,它通常是不可见的,例如一个网格或者一个垂直的列表. Android提供XML词汇与View或者ViewGroup的子类的对应,这样的话你就可以通过XML元素的层级嵌套来定义你的UI. 另一种布局 使用XML声明UI比在运行时代码中声明更有用处可以在很多地方

[email&#160;protected]一个高效的配置管理工具--Ansible configure management--翻译(十二)

如无书面授权,请勿转载 第五章 自定义模块 External inventories In the first chapter we saw how Ansible needs an inventory file, so that it knows where its hosts are and how to access them. Ansible also allows you to specify a script that allows you to fetch the inventor