一个项目中的两个ui视图-选项卡问题

时间:2019-05-15 10:18:58

标签: angularjs uiview routing tabs

我想在标签内显示内容,并为每个标签添加路由。因此,在以下路径中:/ app / test / tab1我想拥有tab1的内容,在路径/ app / test / tab2中我想拥有tab2的内容,当我键入/ app / test时,我会喜欢重定向到app / test / tab1。

所以我有一个测试模块:

   angular
     .module('app.test', [
    /* vendor */
    'ui.router'
  ])
  .config(function ($stateProvider, $urlRouterProvider) {

    $stateProvider
      .state('test', {
        url: '/test',
       templateUrl: 'app/core/test/test.html',
       controller: 'TestController',
      })
      .state('test.tab1', {
        url: '/tab1',
        templateUrl: 'app/core/tab1/tab1.html',
        controller: 'tab1Controller',
      })
      .state('settings.list2', {
        url: '/tab2',
        templateUrl: 'app/core/tab2/tab2.html',
        controller: 'tab2Controller',
      })

在选项卡1中: <p>Content of tab1</p>

并在标签2中 <p>Content of tab2</p>

内部测试

<div>Test</div>
<a ui-sref="test.tab1">Tab1</a>
<a ui-sref="test.tab2">Tab2</a>
<div ui-view></div>

内部索引:

<body>
     <div data-menu></div>
     <div class="container">
     <div data-ui-view=""></div>
     <div data-footer></div>
</body>

我还有多个具有状态的模块,在我向测试文件中添加第二个ui-view之前,它可以正常工作。 当我单击Tab1或Tab 2时,这些标签中的内容不会显示

这是怎么了?

0 个答案:

没有答案