Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – Angular UI-Router多个视图大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用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

大佬总结

以上是大佬教程为你收集整理的angularjs – Angular UI-Router多个视图全部内容,希望文章能够帮你解决angularjs – Angular UI-Router多个视图所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。