我是 Ionic 的新手,我对这个问题感到震惊。我的问题是,如果我从中选择任何菜单,{{menu.menuName}}
它将滑动到相应的选项卡,但只有当我在app/home
此 URL 以外的情况下才会发生这种情况。请帮忙。
菜单.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}} <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>
控制器.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);
};
应用程序.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app.home',{
url:'/home',
cache:false,
views:{
'menuContent':{
templateUrl:'templates/home.html',
controller:'HomeCtrl'
}
}
})
.state('app.profileUpdate',{
url:'/profileUpdate',
cache:false,
views:{
'menuContent':{
templateUrl:'templates/profileUpdate.html',
controller:'ProfileUpdate'
}
}
});
$urlRouterProvider.otherwise('/app/home');
});
主页.html
<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>