angular.js - angular ui-router跳转
给我你的怀抱
给我你的怀抱 2017-05-15 16:56:01
0
1
552
app---
    a---
      a.index.html  
    b---
      b.index.html
b.index.html

<a ui-sref="a.index">show a.index.html</a>
<p ui-view></p>

怎样让ui-view这个p显示的是a.index.html?

ui-view默认读的是哪里的?ui-view是由哪里控制的?

而且 ui-sref 编译后那个 a 标签没有 href 属性

给我你的怀抱
给我你的怀抱

reply all(1)
某草草
angular.module("mainApp")
    .config(function ($stateProvider, $urlRouterProvider) {
        $stateProvider
            .state("a", {
                url: '/a',
                templateUrl: 'app/a/a.html'
            })
            .state("b", {
                url: '/b',
                templateUrl: 'app/b/b.html'
            })
        
        
app/index.html:


....
<p ui-view></p>
....
        

ui-router is through the position of state进行页面跳转控制的,具体来说,当一个页面加载了ui-router及其相关router配置后(上面的示例代码),会跟据地址栏的url加载对应的模板,比如上文,如果访问了/a这个路径,ui-router会知道这个/a路径对应a这个state,他的模板是app/a/a.html,之后就会加载这个模板,并把它塞到ui-view这个directive (this may not be very appropriate, because state can be inherited and views can also be nested, which is a far stretch)

It is recommended to take a good look at the ui-router wiki

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!