I'm new to Ionic, and I'm doing an app that from a button, calls a function in a controller. The function makes http and brings data with php to make a list in another view. But ... the view is loaded and the data is not yet available. (The PHP works correctly) In addition, I have variable logic, which indicates when the view is loaded that even the data is not. I will appreciate if you help me solve this ... asynchronism? Thank you very much!
var request = $http({
method: "post",
url: "http://............php",
data: {
ciudad: $scope.ciuid,
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
/* Successful HTTP post request or not */
request.success(function (data) {
$scope.arrs = [];
for (var prop in data) {
$scope.arrs.push(data[prop]);
}
$scope.AtraccLoaded = true;
alert($scope.arrs[0].aarqu); // muestra dato, correcto !
View ----------------------------------
<a ng-repeat="arr in arrs" ng-if="AtraccLoaded"
href="#/{{arr.anomb}}"
class="item item-thumbnail-left">
<img ng-src="{{ arr.imag }}">
<h2>{{ arr.anomb }}</h2>
<h4>{{ arr.adire }}</h4>
</a>