我试图使用新的1.5路由器和角度组件接吻路线,但我出现了嵌套组件的问题
.state('custom', {
abstract: true,
url: '/custom,
component: 'custom'
})
.state('custom.children', {
url: '/children',
component: 'customChildren'
})
customChildren
组件有以下模板:
<p>Lorem Ipsum</p>
<div>
<h1>My Title</h1>
<div ui-view class='settings-content'
custom-children-attr='$ctrl.childrenValue'>
</div>
</div>
custom
组件:
class CustomController {
constructor() {
...
}
$onInit() {
this.childrenValue = 'test';
}
$onChanges(changes) {
...
}
}
angular
.module('app')
.component('custom', {
templateUrl: 'custom.html',
controller: CustomController
});
customSon
就是这样:
class CustomChildrenController {
constructor(...) {
...
}
$onInit() {
...
}
$onChanges(changes) {
...
}
}
angular
.module('app')
.component('customChildren', {
templateUrl: 'custom-children.html',
controller: CustomChildrenController,
bindings: {
customChildrenAttr: '<'
}
});
当我转到/custom/children
时,我无法获得customChildrenAttr
的值。我如何获得customChildrenAttr
绑定?我尝试过决心和其他事情,但我不能让它发挥作用。