如何隐藏一次angularjs选择下拉菜单 [英] how to hide a dropdown menu once selected in angularjs
问题描述
您好我是新来angularjs,使下拉菜单的演示,我想一旦隐藏任何选定的菜单,请帮助我如何做到这一点?
HTML
<跨度类=工具栏按钮 - 静音导航bar__line高的风格=填充:0;>
< I类=离子Android的更多垂直的风格=FONT-SIZE:26px;保证金:0;填充:0 12px的;下拉菜单=ddMenuOptions下拉模型=ddMenuSelected下拉残疾=dropdownsDisabled>< / I>
< / SPAN>
JS
$ scope.ddMenuOptions = [
{
文字:'精选',
code:'F'
},{
文本:名称(A-Z),
code:'A'
},{
文字:'评级',
code:'M'
},{
文字:'最受欢迎',
code:MP
}
]; $ scope.ddMenuSelected = {
};
一个小提琴会更好。不过,你可以通过使用标志/变量实现这一目标。每当您选择或此变量被更新下拉列表所示。一旦你选择一个选项,变量的值设置为false / true,然后在HTML标记采用NG-秀=yourVariable。
<跨度NG秀=yourVariable>< / SPAN>
只要确保无论何时打开下拉列表,然后选择一个选项,您更新此变量的值。
Hello i am new to angularjs and make a demo of dropdown menu ,I want to hide it once any of menu selected,please help me how to do this?
html
<span class="toolbar-button--quiet navigation-bar__line-height" style="padding: 0;">
<i class="ion-android-more-vertical" style="font-size: 26px; margin: 0; padding: 0 12px;" dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected" dropdown-disabled="dropdownsDisabled"></i>
</span>
js
$scope.ddMenuOptions = [
{
text: 'Featured',
code: 'F'
}, {
text: 'Name (A-Z)',
code: 'A'
},{
text: 'Rating',
code: 'M'
},{
text: ' Most Popular',
code: 'MP'
}
];
$scope.ddMenuSelected = {
};
A fiddle would have been better. Nevertheless, you can achieve this by using a flag/variable. This variable gets updated whenever you select or dropdown is shown. Once you select an option, set the variable's value to false/true and then in the HTML tag use ng-show="yourVariable" .
<span ng-show="yourVariable"></span>
Just make sure you update the value of this variable whenever you open the dropdown and select an option.
这篇关于如何隐藏一次angularjs选择下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!