Hi,

I have just done the Tour of Heroes and I am wondering about ngOnInit().

Why I can implement ngOnInit() like this:
ngOnInit() { this.getHeroes(); }

But not like this:
ngOnInit = () => this.getHeroes();

Or even like this:
ngOnInit = this.getHeroes;

When I use one of the latter two ways, the app will compile and run without 
errors, but no heroes will be loaded.

Working Plunk: https://plnkr.co/edit/ASATGPSt7iiBdDJ80tzu?p=preview
Broken Plunk: https://plnkr.co/edit/ASATGPSt7iiBdDJ80tzu?p=preview

Being used to functional programming, I prefer the latter implementations, 
since they do not require using a special syntax for something, that is 
really just an assignment.

Thanks for your help,
Nuvanda

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
  • [AngularJS] Defin... jeanpierre.hoehmann via Angular and AngularJS discussion

Reply via email to