Angular ui-router嵌套视图 - 不显示任何内容

时间:2017-10-27 11:33:27

标签: javascript angularjs angular-ui-router nested-views

我正在尝试使用angular ui-router为页面实现嵌套视图,并且已经配置了与各种教程匹配的状态定义,但是无法在子视图中显示任何内容,尽管没有错误。控制台。

我正在使用parent.child点表示法尝试以下状态名称:

.state('employees/employeeDetails', {
        url: '/employees/employeeDetails/:id',
        templateUrl: 'pages/employees/employeeDetails/employeeDetails.html',
        controller: 'employeeDetailsController',
        resolve: {
            lazyLoad: function($ocLazyLoad) {
                return $ocLazyLoad.load('js/controllers/employees/employeeDetails/employeeDetailsController.js');
            }
        }
    })

    .state('employees/employeeDetails.mainDetailsTab', {
        url: '/employees/employeeDetails/:id/mainDetails',
        templateUrl: 'pages/employees/employeeDetails/mainDetailsTab.html',
        controller: 'mainDetailsTabController',
        resolve: {
            lazyLoad: function($ocLazyLoad) {
                return $ocLazyLoad.load('js/controllers/employees/employeeDetails/mainDetailsTabController.js');
            }
        }
    })

-

HTML:

<div id="mainContent" data-simplebar>

  <div ui-view="mainDetailsTab" id="mainTab" class="tabContent carousel-item employeeDetailsTab"></div>

  <div ui-view="paymentsTab" id="paymentsTab" class="tabContent carousel-item employeeDetailsTab"></div>

  etc...

1 个答案:

答案 0 :(得分:0)

您不需要重新定义url属性的整个路径,只需添加。

在这种情况下:url:'/mainDetails'