Updated the changes in Plunker as well. 

http://plnkr.co/edit/OP8qHlALY00KrhzDTJV3?p=preview 

On Thursday, 31 March 2016 20:37:04 UTC+5:30, Sander Elias wrote:
>
> Hi Calvin,
>
> Your problem is a JS issue. In the then function you have a different 
> 'this' as in the controller itself
>
> you can fix this like:
> controllers.controller("HomeController", ['$log', '$scope', '$http', 
> 'DummyData', 'FetchCustomers', function($log, $scope, $http, DummyData, 
> FetchCustomers)
> {
>  let $ctrl = this;
>  $ctrl.customers = [];
>  
>  // Call the async method and then do stuff with what is returned inside 
> our own then function
>  $ctrl.customers = FetchCustomers.async().then(function(data) {
>    $ctrl.customers = data.records; // put the data in the controller, the 
> 'this' of this function is unrelated.
>  }); 
> }]);
>
> For more in depth information like this, read through the styleguide 
> <https://github.com/johnpapa/angular-styleguide> 
>

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