<tfoot id='PTDpY'></tfoot>

    <small id='PTDpY'></small><noframes id='PTDpY'>

    <legend id='PTDpY'><style id='PTDpY'><dir id='PTDpY'><q id='PTDpY'></q></dir></style></legend>
      <bdo id='PTDpY'></bdo><ul id='PTDpY'></ul>

    1. <i id='PTDpY'><tr id='PTDpY'><dt id='PTDpY'><q id='PTDpY'><span id='PTDpY'><b id='PTDpY'><form id='PTDpY'><ins id='PTDpY'></ins><ul id='PTDpY'></ul><sub id='PTDpY'></sub></form><legend id='PTDpY'></legend><bdo id='PTDpY'><pre id='PTDpY'><center id='PTDpY'></center></pre></bdo></b><th id='PTDpY'></th></span></q></dt></tr></i><div id='PTDpY'><tfoot id='PTDpY'></tfoot><dl id='PTDpY'><fieldset id='PTDpY'></fieldset></dl></div>

        AngularJS UI-Router 多页

        AngularJS UI-Router multiple pages(AngularJS UI-Router 多页)

          1. <legend id='C4J1d'><style id='C4J1d'><dir id='C4J1d'><q id='C4J1d'></q></dir></style></legend>
            <tfoot id='C4J1d'></tfoot>
            <i id='C4J1d'><tr id='C4J1d'><dt id='C4J1d'><q id='C4J1d'><span id='C4J1d'><b id='C4J1d'><form id='C4J1d'><ins id='C4J1d'></ins><ul id='C4J1d'></ul><sub id='C4J1d'></sub></form><legend id='C4J1d'></legend><bdo id='C4J1d'><pre id='C4J1d'><center id='C4J1d'></center></pre></bdo></b><th id='C4J1d'></th></span></q></dt></tr></i><div id='C4J1d'><tfoot id='C4J1d'></tfoot><dl id='C4J1d'><fieldset id='C4J1d'></fieldset></dl></div>

          2. <small id='C4J1d'></small><noframes id='C4J1d'>

                  <bdo id='C4J1d'></bdo><ul id='C4J1d'></ul>
                    <tbody id='C4J1d'></tbody>
                • 本文介绍了AngularJS UI-Router 多页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  由于 Angular 是非常棒的 SPA,但如果我需要一些与 index.html 无关的其他页面,那么 UI-Router 状态如何通过不同的 ui-views 实现?

                  As Angular is SPA that's terrific, but what if I need some other page not related to index.html, how is realised by UI-Router states with different ui-views?

                  例如,我有 index.html:

                  <!DOCTYPE html>
                  <html data-ng-app="npAdmin">
                  <head>
                  ...
                  </head>
                  <body>
                     <header>
                        <data-user-profile class="user-profile"></data-user-profile>
                    </header>
                  
                    <section class="content-wrapper">
                        <aside data-main-menu></aside>
                        <div class="main-content" data-ui-view></div>
                    </section>
                  
                    <footer class="row"></footer>
                  ...
                  </body>
                  </html>
                  

                  app.js:

                  var app = angular.module('npAdmin', ['ui.router']);
                  
                  app.config(['$httpProvider', '$stateProvider', '$urlRouterProvider', function($httpProvider, $stateProvider, $urlRouterProvider) {
                  
                      $stateProvider
                      .state('dashboard', {
                          url: '/dashboard',
                          templateUrl: '/app/dashboard/dashboard.html',
                          controller: 'DashboardCtrl'
                      })
                      .state('crm', {
                          url: '/crm',
                          templateUrl: '/app/crm/crm.html',
                          controller: 'CrmCtrl'
                      })
                  ...
                  

                  现在我需要与 index.html 完全不同的 login.html(不需要索引的页眉、页脚、侧边栏),但配置 stateProvider 只查看 index.html ui-view 和更改各国对此感到满意.login.html如何结合?

                  Now I need login.html which is totally different from index.html (don't need index's header, footer, sidebar) but config stateProvider only looks to index.html ui-view and changes content to it by states. How to combine login.html?

                  好像没那么难,但我不明白.

                  It seems not that hard, but I don't get it.

                  推荐答案

                  如你所料,没那么难,有一个plunker.

                  As you expected, it is not so difficult, there is a plunker.

                  诀窍是移动特定模板内所有视图的通用内容,例如common.html 并创建抽象状态.换句话说,index.html 将保持干净:

                  The trick is to move the common stuff for all views inside of the specific template e.g. common.html and create the abstract state. Other words, the index.html will remain clean:

                  <body>
                  
                      <div ui-view=""></div>
                  </body>
                  

                  并且它之前的内容(index.html的内容)会被移动到common.html.状态定义可能如下所示:

                  And its previous content (content of the index.html) would be moved to common.html. The state definition could look like this:

                  $stateProvider
                    .state('common', {
                      templateUrl: 'tpl.common.html',
                      abstract: true,
                    })
                    .state('dashboard', {
                      url: '/dashboard',
                      parent: 'common',
                      ...
                    })
                    .state('crm', { 
                      url: '/crm',
                      parent: 'common',
                      ...
                    })
                    .state('login', {
                      url: '/login',
                      templateUrl: 'tpl.login.html',
                    });
                  
                  $urlRouterProvider.otherwise('/crm');
                  

                  有趣 (我想说) 是我们引入了 abstract 状态,没有 url.所以所有当前的逻辑都将保留,只是摘要将扮演布局模板的角色.

                  What is interesting (I'd say) is that we introduced abstract state, without url. So the all current logic will remain, just the abstract will play role of a layout template.

                  在此处查看更多信息:示例

                  这篇关于AngularJS UI-Router 多页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                    <i id='RvoDx'><tr id='RvoDx'><dt id='RvoDx'><q id='RvoDx'><span id='RvoDx'><b id='RvoDx'><form id='RvoDx'><ins id='RvoDx'></ins><ul id='RvoDx'></ul><sub id='RvoDx'></sub></form><legend id='RvoDx'></legend><bdo id='RvoDx'><pre id='RvoDx'><center id='RvoDx'></center></pre></bdo></b><th id='RvoDx'></th></span></q></dt></tr></i><div id='RvoDx'><tfoot id='RvoDx'></tfoot><dl id='RvoDx'><fieldset id='RvoDx'></fieldset></dl></div>

                    <small id='RvoDx'></small><noframes id='RvoDx'>

                  1. <tfoot id='RvoDx'></tfoot>

                          <bdo id='RvoDx'></bdo><ul id='RvoDx'></ul>
                            <tbody id='RvoDx'></tbody>

                          <legend id='RvoDx'><style id='RvoDx'><dir id='RvoDx'><q id='RvoDx'></q></dir></style></legend>