I'm trying to get an better understanding of Angular 2. I am receiving a list of people from endpoint and periodically the list changes. People Component:
@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[];
}
Attendees Component:
@Component({
selector: 'attendees',
templateUrl: '<span>{{attendees}}</span>',
})
export class AttendeesComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
I've looked for a way to change automatically update my template whenever the value of input changes. I have yet to find a way of doing this. I've thought about doing a setTimout, but there has to be more efficient way. Can someone assist me or point me in the right direction? I need the ngFor to update dynamically.