Thx. I understand :) Your code works. I just changed 
me.aParameter = data;
... to ...
return data;

both works but i find it looks nicer :) thank you ... i wasted a lot of 
time on this problem.

Am Dienstag, 22. März 2016 16:35:10 UTC+1 schrieb Gabriele Ciech:
>
> The problem concerns the scope of the anonymous function function(data), 
> when you do this. in the anonyomous function you refer to the scope of the 
> function not to the scope of the controller.
> Do this instead:
> .controller('FacebookAdController', function($grabber) {
>     var me = this;
>     me.aParameter = $grabber.getAd(
>         function(data) {
>             me.aParameter = data;
>         }
>     );
> });
>
>
>
> Il giorno martedì 22 marzo 2016 16:11:58 UTC+1, Norman Braun ha scritto:
>>
>> I know there are a lot of entries about this problem out there. but i 
>> just don't get it work. This is my current code:
>>
>> .controller('FacebookAdController', function ($grabber) {
>>
>>     this.aParameter = $grabber.getAd(
>>         function(data){
>>             this.aParameter = data;
>>             console.log(data);
>>         }
>>     );
>>
>>     console.log(this.aParameter);
>>
>>  });
>>
>>
>> First console.log outputs the correct data. the console.log below dont. I 
>> know the problem is that its loaded async. But how can i work with the 
>> parameters in my controller, which came from the resource?
>>
>> thx
>> Norman
>>
>

-- 
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