Reputation: 7083
I have event coming in using socket.io and pushed it to array object, Now i see its being added to array but its not updating or binding to the view if click on that component then i see it gets updated , Do we have something like ng-blur
options in angular 4 so we can achieve this task ?
secondConfigObject.data
is datasource of data grid i am using.
stream.component.ts
ngOnInit() {
this.socket.on('newMessage', (newEvent) => {
console.log('New Event', newEvent);
this.sortArray(newEvent);
});
}
sortArray(newEvent){
var streamArray = this.secondConfigObject.data;
streamArray.push(Object.assign({},newEvent.data));
}
Upvotes: 3
Views: 220
Reputation: 222522
you can manually trigger using ChangeDetectorRef
constructor(private cdr:ChangeDetectorRef) {
}
sortArray(newEvent){
var streamArray = this.secondConfigObject.data;
streamArray.push(Object.assign({},newEvent.data));
this.cdr.detectChanges();
}
Upvotes: 4