甚至认为数组$ scope.allAppDetails第一次被填充。下次我使用$ scope.selectApp函数时,我的数组是空的

时间:2016-01-02 15:04:50

标签: javascript angularjs single-page-application

angular.module(" orgTools")。控制器(" AndroidStatsCtrl",功能($ scope){

    var selectedApp= null;    
    var PerAppDetails= null;
     $scope.allAppDetails= [];
     $scope.perAppStat= PerAppDetails;
     $scope.allAwApps=awAppCategories;
     $scope.processStart=false;
     $scope.allAppsPresent =allApps;$scope.showContent = function($fileContent){

   $scope.allAppDetails.push.apply($scope.allAppDetails, 
                        processFile($fileContent));
        getAllAppCategories($scope.allAppDetails);
       selectedApp= null;
      showLoadGif("loadgifBatteryStat","id","hide");
      $scope.allAWApps=awAppCategories;
      $scope.allAppsPresent=allApps;

};


  $scope.isSelected= function(appSel){

     return  selectedApp===appSel?"btn-primary":"";
  }

//在此函数内部,当我从ng-click使用它时,变量//$scope.allAppDetails变为空。

  $scope.selectApp = function (newAppSel) {
         selectedApp = newAppSel;
         for(item in $scope.allAppDetails)
            {
              if(allAppDetails[item].name===newAppSel)
                appDetails=allAppDetails[item];

            }

     }

0 个答案:

没有答案