Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. I tried using async pipe and also track by
  2.  
  3.  
  4. // in the service
  5. getVehicles(){
  6. obj = { data: [{name: 'car 1'},{name: 'car 2'}] }
  7. return Observable.interval(2200).map(i=> obj.data.push({name: 'car 3'}));
  8. }
  9.  
  10.  
  11. // in the controller
  12. vehicles: Observable<Array<any>>
  13. ngOnInit() {
  14. this.vehicles = this._vehicleService.getVehicles().obj.data;
  15. }
  16.  
  17.  
  18. // in template
  19. <div *ngFor='let vehicle of vehicles | async'>
  20. {{vehicle.name}}
  21. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement