简体   繁体   中英

angular-ui / ui-router nested states not inheriting custom data

The method described for states to inherit custom data from parent state seems to not be working.

System = {
        name: 'System',
        url: '/System',
        controller: 'SystemHomeController',
        templateUrl: '/Content/html/SystemAdmin/Home.html',
        data: {
            level: "system"
        }
    },
    SystemAuditing = {
        name: "System.Auditing",
        url: "/Auditing",
        controller: 'AuditController',
        templateUrl: '/Content/html/Angular/Index.html',
        parent: 'System'
    };
$stateProvider
    .state(System)
    .state(SystemAuditing);

If I've understood what's at the link properly, when I'm at the child state, $state.current.data should contain the {level: "system"} within. I've also tried setting the parent as an object, allowing it to be implied by the name, and defining the name through the call to $stateProvider.State(, ). The home view includes the tag and is rendering properly. But a console.log() from the child state's controller just doesn't show any of it there

{ 
"name": "System.Auditing", 
"url": "/Auditing", 
"controller": "TransferAuditController", 
"templateUrl": "/Content/html/Angular/Index.html", 
"parent": "System", 
} 

Inherited custom data just landed and is not part of the stable release. You'll have to build ui-router manually. https://github.com/angular-ui/ui-router/blob/master/README.md#developing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM