Angular JS中的一个状态多个控制器

时间:2018-01-13 12:43:29

标签: angularjs

我需要单州多重网址的帮助。

angular.module('MasterUISmartReportModule')
    .config(['WcTranslateConfiguratorServiceProvider', '$urlRouterProvider', '$stateProvider',
        function (WcTranslateConfiguratorServiceProvider, $urlRouterProvider, $stateProvider) {

        $stateProvider
            .state('MasterUISmartReport',
            {
            'abstract': true,
            url: '/MasterUISmartReport',
            templateUrl: 'MasterUISmartReport/MasterUISmartReportTemplate.html',
            controller: 'MasterUISmartReportController',
            controllerAs: 'MasterUISmartReportController'
            })

            .state('MasterUISmartReport.EngineeringChangesReport',
            {
            url: '/EngineeringChangesReport',
            templateUrl: 'MasterUISmartReport/states/EngineeringChangesReport/BrokenEngineeringTemplate.html',
            controller: 'EngineeringChangesController',
            controllerAs: 'EngineeringChangesController',
            parent: 'MasterUISmartReport'
            })

            .state('MasterUISmartReport.EngineeringChangesReport',
            {
            url: '/EngineeringChangesReport',
            templateUrl: 'MasterUISmartReport/states/EngineeringChangesReport/ManualyReplaceSmartTemplate.html',
            controller: 'EngineeringChangesController',
            controllerAs: 'EngineeringChangesController',
            parent: 'MasterUISmartReport'
            })

1 个答案:

答案 0 :(得分:0)

$stateProvider
    .state('settings', {
        url: '/settings',
        templateUrl: 'templates/settings.html'
    })
    .state('settings.profile', {
        url: '/profile',
        templateUrl: 'templates/profile.html',
        controller: 'ProfileController'
    })
    .state('settings.account', {
        url: '/account',
        templateUrl: 'templates/account.html',
        controller: 'AccountController'
    });
// this is templates/settings.html

<h1>Settings Level</h1>
<a ui-sref="settings.profile">Show Profile</a>
<a ui-sref="settings.account">Show Account</a>
<div ui-view></div>