我使用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我想有一个嵌套视图:
对于/ 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。