Search code examples
angularjscordova-plugins

If loop is not working in AngularJS function


I am new to ionic therefore to cordova so in my controllers .js i am having a function defined as :

$scope.deleteFingerPrint = function() {
  $scope.disableFingerPrint = true;
  ss.remove(
    function(key) {
      console.log('Removed ' + key);
    },
    function(error) {
      console.log('Error, ' + error);
    },
    'token');
  localStorage.removeItem('isFingerPrintRequired');
  localStorage.removeItem('hasEnrolledFingerprints');
  isFromIosUserValidation = false;
  $scope.deletePopup.close();
  $ionicSideMenuDelegate.toggleLeft();
}

The code works fine but if i try to modify it like this:

$scope.deleteFingerPrint = function() {
  $scope.disableFingerPrint = true;
  ss.remove(
    function(key) {
      console.log('Removed ' + key);
    },
    function(error) {
      console.log('Error, ' + error);
    },
    'token');
  localStorage.removeItem('isFingerPrintRequired');
  localStorage.removeItem('hasEnrolledFingerprints');
  if (isIOS == true) {
    isFromIosUserValidation = false;
  }
  $scope.deletePopup.close();
  $ionicSideMenuDelegate.toggleLeft();
}

The popup comes but $scope.deletePopup.close(); doesnot works and the popup remains as it is. What is the issue and why it is not getting closed. I have mentioned isIOS and isFromIosUserValidation globally.


Solution

  • Where did you define your isIOS variable, maybe the condition is not working so it give error. Please write code properly to understand the problem.