简体   繁体   English

angular-ui / ui-router嵌套状态不继承自定义数据

[英]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. 如果我正确理解了链接的内容,那么当我处于子状态时,$ state.current.data应该在其中包含{level:“ system”}。 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(, ). 我还尝试将父级设置为对象,允许其隐含名称,并通过调用$ 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 但是子状态控制器的console.log()只是不显示任何状态

{ 
"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. 您必须手动构建ui-router。 https://github.com/angular-ui/ui-router/blob/master/README.md#developing https://github.com/angular-ui/ui-router/blob/master/README.md#developing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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