Hide the loading data message with ionicLoading

Hi ! How can i hide the loading message just at the time that the data finish the loading of json data? i just hardcode the duration below at duration: 10000,.

.controller('MyController', function($scope, Api, $ionicLoading, $timeout) {
  $scope.data = null;
  Api.getApiData().then(function(result) {
    $scope.data = result;
 })
  $ionicLoading.show({
    duration: 10000,
    noBackdrop: true,
    template: '<p class="item-icon-left">Loading...<ion-spinner icon="lines"/></p>'
  });
})
.controller('MyController', function($scope, Api, $ionicLoading, $timeout) {
  $scope.data = null;
  
  $ionicLoading.show({
    noBackdrop: true,
    template: '<p class="item-icon-left">Loading...<ion-spinner icon="lines"/></p>'
  });
Api.getApiData().then(function(result) {
    $scope.data = result;
    $ionicLoading.hide();
 })

})

Perfect! work´s fine, thank´s a lot @webslinger

2 Likes