I call API and return the response for binding in $ionicView.beforeEnter
. However, when the view is entered, sometimes I got the view loaded but the data is not being bind until few seconds later, especially in a bad network connectivity. How could this issue be solved?
Would this because of my API call is asynchronous?
angular.module('app').controller(function($scope, ApiMethod) {
$scope.$on("$ionicView.beforeEnter", function(event, data){
ApiMethod.GetFormInfo().$promise.then(function (res) {
$scope.res = res;
}, function (errRes) {
})
});
});
<ion-content>
<form name="form">
<div class="list">
<label class="item item-input">
<input type="text" placeholder="First Name" ng-model="res.firstName">
</label>
<label class="item item-input">
<input type="text" placeholder="Last Name" ng-model="res.lastName">
</label>
<label class="item item-input">
<textarea placeholder="Comments" ng-model="res.comments"></textarea>
</label>
</div>
<button type="submit">Submit</button>
</form>
</ion-content>