【发布时间】:2017-10-22 20:53:56
【问题描述】:
我正在尝试更好地了解 Angular 2。我从端点接收人员列表并定期更改列表。人员组件:
@Component({
selector: 'people-display',
template: <ol class="people-list">
<li *ngFor="let person of people">
<attendees [people]="peopleValue"></attendees>
</li>
</ol>
})
export class PeopleComponent implements OnChanges {
@Input() people: string[];
}
与会者组件:
@Component({
selector: 'attendees',
templateUrl: '<span>{{attendees}}</span>',
})
export class AttendeesComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
我一直在寻找一种在输入值更改时自动更新我的模板的方法。我还没有找到这样做的方法。我考虑过做一个 setTimout,但必须有更有效的方法。有人可以帮助我或指出我正确的方向吗?我需要 ngFor 动态更新。
【问题讨论】:
标签: angular angular2-template ngfor