【发布时间】:2015-10-21 21:42:14
【问题描述】:
我希望有带有章节列表的侧面菜单,例如:chap1、chap2..chap10。点击chap1如何更改内容,内容会显示chap1的内容?内容是从 JSON 文件中检索的。
//路线
.state('chapter', {
url: '/chapter/:aId',
templateUrl: 'templates/chapters.html',
controller: 'ChapterController'
})
//控制器
.controller('ChapterController', function($scope, $stateParams, $http, $ionicSlideBoxDelegate, $ionicSideMenuDelegate){
$http.get('js/bb.json').success(function(data){
$scope.chapters = data.bb;
$scope.imagesArray = [];
data.bb.forEach(function (item) {
if(item.chapter == $stateParams.aId){
item.images.forEach(function (image) {
$scope.imagesArray.push({
src: image
});
});
}
});
$ionicSlideBoxDelegate.$getByHandle('image-viewer').update();
$scope.reloadChap = function(){
$scope.imagesArray = [];
data.bible.forEach(function (item) {
// console.log($stateParams);
if(item.chapter == $stateParams.aId){
item.images.forEach(function (image) {
$scope.imagesArray.push({
src: image
});
});
}
});
}
});
})
我的问题是当我点击 chap2 时,内容不会更改为 chap2 的内容,但上面的 url 已更改为 '/chapter/2'。
万分感谢。
【问题讨论】:
标签: javascript jquery json angularjs ionic