我正在研究一個帶有離子選項卡的網絡應用程序。 在我的一個頁面上,我實現了GitHub的離子樹列表(Ion-tree-list from GitHub)作爲treeview。 在services.js我得到了我的樹源:是否有可能將離子樹列表與導航視圖相結合?
.factory('VerificationTree', function() {
var verificationTree = [
{
id: 'operator',
name: 'Operator'
},
{
id: 'type_of_test',
name: 'Type of test',
},
{
id: 'system',
name: 'System'
},
{
id: 'component',
name: 'Component'
},
{
id: 'component_group',
name: 'Component group',
tree: [
{
id: 'component2',
name: 'Component'
}
]
}
];
return {
all: function() {
return verificationTree;
}
};
})
當我點擊一個樹中的項目 - 體育「type_of_test」 - 我想打開另一個頁面。 在controller.js中,我爲該頁面定義了一個控制器。 控制器內部是一個函數,它通過window.open打開頁面。
.controller('VerificationCtrl', function ($scope, VerificationTree) {
$scope.verificationTree = VerificationTree.all();
$scope.$on('$ionTreeList:ItemClicked', function (event, item) {
if (item.id == 'type_of_test') {
window.open('templates/type-of-test.html');
};
//if (item.id == 'component2') {
// alert('The ion-tree-list item component2 was clicked');
//};
})
})
頁面在新選項卡中打開,但佈局不再好。 是否有可能將樹與導航視圖組合在一起?
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
});
或者又如:
var app = angular.module('myApp', ['ionic']);
app.config(function($stateProvider) {
$stateProvider
.state('index', {
url: '/',
templateUrl: 'home.html'
})
.state('music', {
url: '/music',
templateUrl: 'music.html'
});
});
這個答案看起來在這裏很好!感謝那!有了這種狀態轉換的解決方案,這將是可愛的。 – fer
查看此操場:http://play.ionic.io/app/c0206fc71f2a – OClyde
這是您正在尋找的場景嗎? ;) – OClyde