My application has:
- a page
- a menu
- a data service
a data service will notify when the data is modified to the page, and the page catches this event and update its interface
`
@Injectable
export class DataService {
data = [];
.....
setData(newData) {
this.data = newData;
this.events.publish('data:change', this.data);
}
}
`
The page catches events
`
export class DataPage {
data = [];
.....
ionViewWillEnter() {
this.events.subscribe('data:change',(userEventData) => {
this.data = userEventData[0];
//- print out for test
console.log(this.data);
});
}
}
`
The menu contains some buttons, when tapping on them, we will modify data in the data service.
Tapping on a button of the menu —> change data in the service data —> notify the page ----> the page catches this event , and print out this data on the log, but not update its interface.
Could you tell me why is that? Thanks