I call the API and return the response to bind to $ionicView.beforeEnter. However, when the entered view is entered, sometimes I load the view, but the data is not connected until a few seconds later, especially in case of poor network connection. How to solve this problem?
Will it be asynchronous due to my API call?
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>
source
share