AngularJS 2-way binding before API call is complete -
I am using an original API call to get an array of objects to display in the table. My table is perfectly fine, but I saw that the angle is throwing a bunch of errors so that I can not produce expressions.
I realized that this page is trying to present the second and API call response, angular table split between load and is clearly achieving errors because the table is to populate The array used does not exist yet.
So, what is the standard way to get rid of this problem? Until the API call is complete, I should just use I can also enable it to start the array such as Can someone explain the best way to do this? Another way that it can be controlled is that the and ng-if or ng-hide or some other way to "wait" to make an ATO call Before dome $ scope.dataArray = [] , but I think it is a problem in dealing with complex JSON objects < / P> solution on the router or state provider is using the property. ui-router s $ stateProvider You can do this:
.state ('mystate', {Controller: function ($ scope, data) {$ scope.data = data;}, solution: {data: ['$ http', function ($ http) {return $ http.get ('/ api / get-data The contractor is instantiated before the promise will be promised from ');}]}}) $ http.get () $ CodeProvider ( ngRoute ) Docs: $ routeProvider ngRoute .
Comments
Post a Comment