加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular UI-Router多个视图

发布时间:2020-12-17 08:44:34 所属栏目:安全 来源:网络整理
导读:我使用angular UI-Router。我在我的路由配置中有以下 .config(function config($stateProvider) { $stateProvider.state('newsFeedView',{ url: '/newsFeed',controller: 'newsFeedController',templateUrl: '../src/app/bulletinBoard/views/newsFeed.part.
我使用angular UI-Router。我在我的路由配置中有以下
.config(function config($stateProvider) {
    $stateProvider.state('newsFeedView',{
            url: '/newsFeed',controller: 'newsFeedController',templateUrl: '../src/app/bulletinBoard/views/newsFeed.part.html',data: { pageTitle: 'News Feed' }
        })
        .state('tradeFeedView',{
            url: '/tradeFeed',controller: 'tradeFeedController',templateUrl: '../src/app/bulletinBoard/views/tradeFeed.part.html',data: { pageTitle: 'Trade Feed' }
        })
        .state('bulletinBoard',{
            url: '/bulletinBoard',views: {
                'tradeFeed': {
                    url: "",templateUrl: '../src/app/bulletinBoard/views/tradeFeed.part.html'
                },'newsFeed': {
                    url: "",templateUrl: '../src/app/bulletinBoard/views/newsFeed.part.html'
                }
            },templateUrl: '../src/app/bulletinBoard/views/bulletinBoard.part.html'
        });
})

在我的索引页面,我只是调用视图使用:

<div class="container" ui-view></div>

在我的公告BOo.html我想有一个嵌套视图:

<div ui-view="tradeFeed"></div>
<div ui-view="newsFeed"></div>

对于/ newsFeed页面和/ tradeFeed页面,这是完美的,但对于公告板,我看不到任何东西在页面上。我在哪里错了?

我发现在官方的GitHub wiki的例子是非常不直观。这里是一个更好的一个:

https://scotch.io/tutorials/angular-routing-using-ui-router

例如:

...

.state('bulletinBoard',{
    url: '/bulletinBoard',views: {

        // the main template will be placed here (relatively named)
        '': { templateUrl: '../src/app/bulletinBoard/views/bulletinBoard.part.html' },// the child views will be defined here (absolutely named)
        'tradeFeed@bulletinBoard': { template: ..... },// another child view
        'newsFeed@bulletinBoard': { 
            templateUrl: ......
        }
    }

});

每个视图属性的语法为viewName @ stateName。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读