2
子组件中的submitted
是否可以始终等于父组件中的submitted
?由于如何让孩子和父母成分的价值始终如一?
@Component({
selector: 'child-cmp',
template: `
child:{{submitted}}
`
})
class ChildCmp {
@Input('submitted') submitted: boolean;
ngOnInit() {
this.submitted = true;
}
}
@Component({
selector: 'app',
template: `
<child-cmp [submitted]="submitted"></child-cmp>
parent:{{submitted}}
`,
directives: [ChildCmp]
})
class App {
submitted: boolean;
}
bootstrap(App);
您已经接受了下面这就是罚款。但是你的代码有什么错误。你知道吗?你的代码也在工作,除了你忘记把'export'关键字放在我猜的事实上。 – micronyks
@micronyks感谢您的帮助。我的问题中的代码不清楚是我的错。我会更新我的问题来说清楚。看到这个:他们现在不是平等的:http://plnkr.co/edit/5WOc85NcAwlgI5VZBSkq?p=preview。 –