Reputation: 189
I am not getting result when i am loading the app.
but i am getting the result when clicking the button
<button ion-item (click)="goToDrivePage()">
but i need to load automatically when loading the app. any body help to get result?
Upvotes: 0
Views: 32
Reputation: 910
You can do it in your app component constructor or ngInit function like
export class AppComponent implements OnInit {
ngOnInit() {
this.dataService.getData()
.subscribe((data: any) => {
this.data = data;
});
}
//OR
constructor() {
this.dataService.getData()
.subscribe((data: any) => {
this.data = data;
});
}
}
Upvotes: 1