ionic how to display a dropdown of choices on button click

十年热恋 提交于 2020-01-07 05:53:58

问题


I am just starting with ionic framework, trying to redo an existing bootstrap / angular application to mobile as a hybrid app.

Is there an idiomatic way to do a dropdown menu in ionic? I have searched the ionic website/forums and also googled but no luck. Like bootstrap single button dropdown. I am OK with JavaScript but HTML/CSS is not my cup of tea.

Will appreciate your help.

--EDIT

Thanks TechMa9iac. I am trying to follow that line.

I am trying to make a 2-level dropdown using angular? I have modeled my data like in the ngSelect doc.

$scope.currSel = null;
$scope.metadata = [
    { proc: "Proc-1", board: "Alloc" },
    { proc: "Proc-1", board: "Manager" },
    { proc: "Proc-1", board: "Ops" },
    { proc: "Proc-2", board: "Alloc" },
    { proc: "Proc-2", board: "Manager" },
    { proc: "Proc-3", board: "Alloc" },
    { proc: "Proc-3", board: "Manager" }
];

HTML

<span>{{item.proc}}
<select ng-model="currSel"
        ng-options="item.board group by item.proc 
                        for item in metadata">
</select>

I show the proc value separately in html because the select text area shows only board value (the label in select).


回答1:


when the ng-model in an ng-options is an object, it must be an object reference to one of the value array / dict elements. It cannot be an angular.copy.

Updated plunker



来源:https://stackoverflow.com/questions/27139785/ionic-how-to-display-a-dropdown-of-choices-on-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!