I have read on constructor and ngOnInit. And myself have came to a conclusion that we should make variable and service initialization in constructor and any logic in ngOnInit. And this seems clean to me.
Here is my sample of implementation. Hope to get some feedback if i am doing it right or i am understanding the constructor and ngOnInit wrongly. Or should i just put everything on ngOnInit instead.
constructor(
public loading: LoadingController,
public auth: AuthService,
public data: DataService
) {
this.existingProfile = new EventEmitter<Profile>();
this.loader = this.loading.create({
content: 'Loading...'
});
}
ngOnInit() {
this.loader.present();
this.data.getProfile().subscribe(profile => {
this.userProfile = profile;
this.existingProfile.emit(this.userProfile);
this.loader.dismiss();
});
}