gpt4 book ai didi

javascript - 如何在 Ionic Side 菜单中创建下拉菜单?

转载 作者:行者123 更新时间:2023-11-30 09:51:24 24 4
gpt4 key购买 nike

如何在 ionic 框架中创建子菜单?我是 AngularJs 和 ionic 框架的新手。我正在尝试创建一个下拉列表组件。我能够用下面的代码做到这一点。 enter image description here

<ion-side-menu side="left">
<ion-content class="has-expanded-header">
<ion-list>
<ion-item nav-clear menu-close class="item-icon-left" ui-sref="main.dashboard">
<i class="icon ion-ios-speedometer"> </i>
Dashboard
</ion-item>
<ion-item nav-clear menu-close class="item-icon-left item-icon-right" ui-sref="main.accounts">
<i class="icon ion-accounts ion-ios-arrow-right"> </i>
Accounts
</ion-item>
<ion-item nav-clear menu-close class="item-icon-left" ui-sref="main.accounts">
<i class="icon ion-accounts"> </i>
sub Accounts 1
</ion-item>
<ion-item nav-clear menu-close class="item-icon-left" ui-sref="main.accounts">
<i class="icon ion-accounts"> </i>
sub Accounts 2
</ion-item>
</ion-list>
</ion-content>
</ion-side-menus>

最佳答案

html代码:

<ion-list>
<div ng-repeat="group in groups">
<ion-item class="item-stable"
ng-click="toggleGroup(group)"
ng-class="{active: isGroupShown(group)}">
<i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
&nbsp;
Group {{group.name}}
</ion-item>
<ion-item class="item-accordion"
ng-repeat="item in group.items"
ng-show="isGroupShown(group)">
{{item}}
</ion-item>
</div>
</ion-list>

Controller 代码:

 $scope.groups = [];
for (var i=0; i<10; i++) {
$scope.groups[i] = {
name: i,
items: []
};
for (var j=0; j<3; j++) {
$scope.groups[i].items.push(i + '-' + j);
}
}

$scope.toggleGroup = function(group) {
if ($scope.isGroupShown(group)) {
$scope.shownGroup = null;
} else {
$scope.shownGroup = group;
}
};
$scope.isGroupShown = function(group) {
return $scope.shownGroup === group;
};

希望这对你有帮助:)

关于javascript - 如何在 Ionic Side 菜单中创建下拉菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36311426/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com