javascript - Handling data through $resource in Angular -


i'm trying figure out best handle working async data.

basically, receive data controller doing:

 userresource.query(function (res) {       $scope.user = res;  }); 

this works fine, there's flickering. example, if i'm using along directive (such bootstrap select), render select first (with no data), show correctly.

is there elegant way handle this, without creating lots of additional parameters check values , show/hides ng-switch.

any tips/best practice suggestions great!

thank you

using $resource promise pr commit slated 1.1.3

$scope.userresource = function() {     var promise = userresource.get().$promise.then(         function( res ){             $scope.user = res;         },         function( error ){             //something went wrong!         }     )     return promise; } 

ran myself recently: callback after async foreach angularjs

edit:

@dave had catch --- is, in 1.1.4 convention changes too:

userresource.get().$then() ... 

$then returned on $resource object directly.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -