2016-11-04 90 views
1

我得到这个错误只有ios 9.它工作正常和android和浏览器。我真的不明白为什么这只是IOS发生9离子ios9错误:[ng:areq]参数'TabCtrl'不是函数,得到undefined

注:当我清理内部位指示代码,它工作正常。

我的代码:

angular.module('starter') 

.controller('TabsCtrl', function($scope, $rootScope, $ionicPlatform, $state, $cordovaCamera, $cordovaFileTransfer, $cordovaFile, $ionicLoading, $ionicTabsDelegate, $ionicModal, $ionicActionSheet, AuthService, httpService, imageService, API) { 

    // initialize tab's modal page 
    $scope.profile_picture = "img/profile.jpg"; 
    $scope.social = {}; 
    $scope.pic = {}; 
    $ionicPlatform.onHardwareBackButton(function(event){ 
     if (window.localStorage['is_user_info_compelete'] != 1) { 
      ionic.Platform.exitApp(); 
     } 
    }) 

    window.localStorage['is_user_info_compelete'] = 1; 


    $scope.getStateByServer = function() { 
     httpService.handleRequest(new Array(), API.url+'state/getAll', function() {}, function() {}, '').then(function(result) { 
      $scope.$broadcast('scroll.refreshComplete'); 
      $rootScope.states = result.data[0]; 
      $rootScope.cities = result.data[1]; 
      $scope.states = $rootScope.states; 
      $scope.cities = $rootScope.cities; 
      $scope.citiesByState = []; 
     }); 
    } 
    $scope.getStateByServer(); 




    // Modal 
    modalOptions = {scope: $scope, animation: 'slide-in-up', backdropClickToClose: false, hardwareBackButtonClose: false}; 
    $ionicModal.fromTemplateUrl('my-modal.html', modalOptions).then(function(modal) { 
     $scope.modal = modal; 
     if (window.localStorage['is_user_info_compelete'] != 1) { 
      setTimeout(function() { 
       $scope.modal.show(); 
      }, 1200); 
     } 
    }); 


    /** 
    * Save all information of the model 
    * Use json_decode for moreData in php like: json_decode($this->input->post("data")); 
    * index 'data' is the name of object in httpService.handleFileSender 
    */ 
    $scope.saveSocialInfo = function(social, city) { 

     if (!$scope.socialValidate(social, city)) {return false;} 

     data = {picture:$scope.profile_picture, city:city, social:social, uploadDirectory: 'upload/profile'}; 
     moreData = [ 
      {token:window.localStorage['yourTokenKey']}, 
      {social:social} 
     ]; 

     $ionicLoading.show(); 
     httpService.handleFileSender(data, moreData, API.url+'social/save/t2AkQ6df0W').then(function(result){ 
      $ionicLoading.hide(); 
      if (JSON.stringify(parseInt(result.response)) == 1) { 
       window.localStorage['is_user_info_compelete'] = 1; 
       $scope.modal.hide(); 
      } 
      else { 
       httpService.popup('خطا', 'ارسال انجام نشد. لطفا مجددا تلاش نمایید.') 
      } 
     }) 
    } 


    // Action Sheet 
    $scope.showActionSheet = function(indexPic = false, width = 500, height = 500, allowEdit = true) { 

     var hideSheet = $ionicActionSheet.show({ 
      buttons: [ 
       {text: 'گرفتن عکس'}, 
       {text: 'انتخاب از گالری'} 
      ], 
      destructiveText: 'پاک کردن', 
      titleText: 'انتخاب یا گرفتن عکس', 
      cancelText: 'لغو', 
      destructiveButtonClicked: function() { 
       $scope.profile_picture = "img/profile.jpg"; 
       return true; 
      }, 
      buttonClicked: function(index) { 
       option = { width:width, height:height, allowEdit:allowEdit, quality:80 } 
       imageService.getImage(index, option).then(function(imageURL) { 
        if (imageURL) { 
         $scope.profile_picture = imageURL; 
         if (indexPic) {$scope.pic[indexPic] = imageURL;} 
        } 
       }) 
       return true; 
      } 
     }); 
    }; 



    $scope.socialValidate = function(social, city) { 
     var title = 'خطا.'; 
     if ($scope.profile_picture == "img/profile2.jpg") { 
      httpService.popup(title, 'اطفا تصویر خود را انتخاب نمایید.'); 
      return false; 
     } 
     if (!httpService.validateObject(social)) { 
      httpService.popup(title, 'حداقل یکی از شبکه های اجتماعی را باید پر کنید.'); 
      return false; 
     } 
     if (!city) { 
      httpService.popup(title, 'اطفا شهر خود را انتخاب کنید.'); 
      return false; 
     } 
     return true; 
    } 


    // Handle tabs swipe 
    $scope.goForward = function() { 
     var selected = $ionicTabsDelegate.selectedIndex(); 
     if (selected != -1) { 
      $ionicTabsDelegate.select(selected + 1); 
     } 
    } 
    $scope.goBack = function() { 
     var selected = $ionicTabsDelegate.selectedIndex(); 
     if (selected != -1 && selected != 0) { 
      $ionicTabsDelegate.select(selected - 1); 
     } 
    } 
    $scope.go = function(state) { 
     $state.go(state); 
    } 
    $scope.destroySession = function() { 
     AuthService.logout(); 
    }; 


    // Get cities by state 
    $scope.getCities = function(mystate) { 
     $scope.citiesByState = []; 
     $scope.arr = []; 
     for (var i = 0; i < $scope.cities.length; i++) { 
      if ($scope.cities[i].stateID == mystate) { 
       $scope.arr.push($scope.cities[i]); 
      } 
     } 
     $scope.citiesByState = $scope.arr; 
    } 


}) 

回答

1

哦,我的上帝。经过一段时间的苦苦挣扎后,终于找到了解决办法。 我正在使用默认功能参数。这由ES6/ES2015支持。正如我使用的语法:

$scope.showActionSheet = function(indexPic = false, width = 500, height = 500, allowEdit = true) { 
} 

ios 9可能不支持这一点。

相关问题