2017-12-13 24 views
0

저는 이오니아를 처음 접했고이 문제에 충격을 받았습니다. 내 문제는 {{menu.menuName}}에서 메뉴를 선택하면 해당 탭으로 슬라이드되지만 위의 URL 이외의 app/home에있는 경우에만 작동합니다. 도움을 요청하십시오. menu.html슬라이더 내용 또는보기가 메뉴 클릭에 따라 변경되지 않음

<ion-side-menu side="left"> 
<ion-header-bar class="bar-balanced"> 
    <h1 class="title">App</h1> 
</ion-header-bar> 
<ion-content> 
    <ion-list> 
    <ion-item menu-close href="#/app/home"> 
     <i class="icon ion-home"></i> Home 
    </ion-item> 
    <ion-item menu-close ng-click="createDirectory()"> 
     <i class="icon ion-android-create"></i> Create Name 
    </ion-item> 
    <ion-list ng-controller="HomeCtrl"> 
     <div ng-repeat="menu in mainMenu "> 
      <ion-item class="item-stable" 
        ng-click="toggleGroup(menu)" 
        ng-class="{active: isGroupShown(menu)}" style="color:#11c1f3;"> 

      {{menu.menuName}} &nbsp; <i class="icon" style="position: absolute; 
right: 8%;" ng-class="isGroupShown(menu) ? 'ion-minus' : 'ion-plus'"></i> 
      </ion-item> 

      <ion-item class="item-accordion" 
        ng-repeat="($index, directories) in directoryList" 
        ng-class="{'': $index === current}" 
        ng-click="changeSlide($index,directoryList)" 
        ng-show="isGroupShown(menu)" style="color:#E47006;" > 
      {{directories.directoryName}} 
      </ion-item> 

     </div> 
     </ion-list> 
    </ion-list> 
</ion-content> 

Controller.js

$scope.changeSlide = function (index,directoryName) 
{ 
console.log('Slide changed to ' + index); 

var data= directoryName[index] 
if(data !=null){ 
var directoryId =data.directoryId; 
data.dirId = directoryId; 
getImages(); 
function getImages() { 
    userService.getImages(data).then(function(response) { 
     $scope.imageData = response; 
     $scope.current = index; 
     $ionicSlideBoxDelegate.slide(index); 
    },function(error) { 

    }) 
} 
} 
$scope.ready.push(index + ': ' + true); 
}; 

를 app.js 973,210

아래에 언급 한 바와 같이 나는 경우에 사람이 필요로하는 경우, 나는이를 추가하고 방법을 변경 한

<ion-view view-title="Home" hide-back-button="true" style="margin-top: 45px;"> 

    <ion-content scroll="false" style="top:0px;" > 

    <ion-slide-box slide-tabs-scrollable="true" show-pager="false" on-slide-changed="changeSlide(index,directoryList)" bounce="false" ion-slide-tabs> 
     <ion-slide ng-repeat="(key, catg) in directoryList" ion-slide-tab-label="{{catg.directoryName}}" style="background-color:white;"> 
<br><br> 

      <div class="row gallery"> 
      <div class="col col-33" ng-repeat="element in imageData" ng-click="showImages($index)"> 
      <img ng-src="data:image/jpeg;base64,{{element.imagePath}}" width="100%" /> 
      </div> 
      </div> 


      <center ng-if="!ready[key]"> 
      <br> 
      <ion-spinner></ion-spinner> 
      </center> 

      <br></br><br></br><br></br> 
     </ion-slide> 
    </ion-slide-box> 
    </ion-content> 
</ion-view> 

답변

0

home.html을,

fetchDirectories(); 

function fetchDirectories(){ 
    userService.fetchDirectories() 
     .then(function(response) { 
      $scope.directoryList = response; 
      $scope.lastView = $ionicHistory.backView() ; 
      if($scope.lastView !=null){ 
      if($scope.lastView.stateName != 'app.home'){ 
      var indexNumber = sessionStorage.getItem("indexNumber"); 
      $scope.changeSlide(indexNumber,$scope.directoryList); 
      } 
      }else{ 
      $scope.changeSlide(0,$scope.directoryList); 
      } 
     window.dispatchEvent(new Event('resize')); 
      }, 
     function(errResponse){ 
     } 
    ); 
}; 

$ scope.changeSlide

$scope.changeSlide = function (index,directoryName) 
{ 
console.log('Slide changed to ' + index); 
if($location.path() == '/app/home'){                     
console.log($location.path()); 
var data= directoryName[index] 
if(data !=null){ 
var directoryId =data.directoryId; 
data.dirId = directoryId; 
getImages(); 
function getImages() { 
    userService.getImages(data).then(function(response) { 
     $scope.imageData = response; 
     $scope.current = index; 
     $ionicSlideBoxDelegate.slide(index); 
     },function(error) { 

    }) 
} 
} 
$scope.ready.push(index + ': ' + true); 
} 
else if($location.path() != '/app/home'){ 
sessionStorage.setItem("indexNumber",index); 
    $state.go('app.home'); 
} 
}