Change `function()` to `()=>`

https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiN0fex39HMAhXF2ywKHWT5DOYQFggbMAA&url=https%3A%2F%2Fdeveloper.mozilla.org%2Fde%2Fdocs%2FWeb%2FJavaScript%2FReference%2FFunctions%2FArrow_functions&usg=AFQjCNFVlx1d6Ugpf5ene4iHJq_5ezUpLQ&sig2=j5tpHdhOxAeqMROs472onw&bvm=bv.121658157,d.bGg&cad=rja

On Monday, May 9, 2016 at 6:35:04 PM UTC+2, Nobody Body wrote:
>
> Hi, i d'ont understand why the following snippet don't works and print 
> error 'TypeError: Cannot read property 'test' of undefined' when i invoke 
> the method : 
>
> @Injectable()
> export class HeroService {
>         test = '1';
>  
>         getHeroesSlowly() {
>                 return new Promise(function(resolve, reject) {
>  
>                         if (this.test=='1') {
>                                  setTimeout(()=>resolve(HEROES), 4000) // 2 
> seconds
>                         } else {
>                                   reject('No user');
>                 }
>                 }); 
>         }
> }
>
>
> And how i can display logs in console? 'console.log('log') not works.
>
> thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" 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.

Reply via email to