首页 > angular的ui-router不显示问题?求帮忙

angular的ui-router不显示问题?求帮忙

$urlRouterProvider.otherwise('/login');
$stateProvider
        .state('first',{    
            url:'/login',   
            templateUrl:'home.html'                  
        })
        .state('first.second',{
            url:'/booklist',
            templateUrl:'second.html'
        })
        

我的home.html是

<div ui-sref="first.second">登陆</div>

我点击home.html页 无法显示second.html,但是地址却已经变成了/booklist,请问这是为什么呢,地址是跟着变过去的,但是内容却不显示出来呢?


home.html 里面写 <ui-view></ui-view> 了吗?

你现在的写法 first.secondfirst 的子路由,渲染模版的时候会自动寻找父级模版內的 <ui-view></ui-view>,如果没提供自然就看不到。如果你并不想渲染到父级模版內,那要么改写路由的从属关系(比如显式指定 first.secondparent 属性,或者重写这个路由),要么通过 views 属性显式指定渲染的目标 <ui-view></ui-view> 在哪里。

还是建议认真读完 ui.router 的文档,信息量非常大的。

【热门文章】
【热门文章】