考虑以下组件:
export class PropertyViewComponent implements OnInit {
@Input() property: any;
constructor() {}
ngOnInit() {
}
onAddClick() {
console.log(this.property);
}
}
和以下模板:
<button type="button" class="btn btn-primary" (click)="onAddClick()">َAdd</button>
父组件模板是:
<app-property-view *ngFor="let p of properties" [property]="p"></app-property-view>
当我运行该应用程序时,它将打印property
中的第一个properties
!正常吗?
这是导致此行为的引导程序模式。