ionicModal stop working


#1

I have an edit function which looks like this:

$scope.editStaff = function(save,staff){
$scope.edit = true;
if (save == false){
  console.log(staff);      
  Staffs.get(staff).then(function(res){
    $scope.modal.show();
    $scope.staffInfo = res;        
  },function(status){
    console.log(status);
  });
}else{
  Staffs.edit(staff).then(function(res){
   $scope.modal.hide();
   $scope.staffInfo = "";
   $scope.init();
  },function(status){
    console.log(status);
  });
}
}

The function flow is:

  • Open the modal and get the staff information from API via service and set into $scope.staffInfo which will be shown in edit staff modal. Then when user click save, send data to API to save changes and close modal and call init function to reload the data on the staff list.
    This is my init function:

    $scope.init = function(){
    var token = Token.get();
    if (!token){
    $state.go(‘signin’);
    }else{
    $ionicLoading.show({
    template: ‘Loading…’
    });
    Staffs.all().then(function(res){
    $scope.staffs = res.content;
    console.log(res)
    $ionicLoading.hide();
    },function(status){
    console.log(status)
    })
    }
    }
    But when I clicked save button for the first time it worked fine, in the second time without changes it stop working and hang on, can’t click and scroll anymore, the console didn’t show any error either. It just stopped working.
    But if I try the same thing with changing the datas and saved, it worked fine, no more hanging on.
    What is the problem? Is it because of my API or the internal issue of ionicModal?
    Thank you.


#2

can any one help me?