我有一个组件
timeBoxSelector HTML:
<input type="checkbox" [(ngModel)]="selected">
TS:
@Component({
...
})
export class TimeboxComponent implements OnInit {
@Input() selected: boolean;
constructor() {}
ngOnInit() {
console.log('Selected: ', this.selected);
}
}
现在,当我创建
<app-timebox selected="false"><app-timebox/>
<app-timebox selected="true"><app-timebox/>
在两种情况下,该复选框最初都显示为选中状态。为什么会这样,我该如何解决?