结合NG-秀在AngularJS一个选择选项 [英] Binding ng-show to a select option in AngularJS

查看:99
本文介绍了结合NG-秀在AngularJS一个选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是非常简单的。您可以轻松地给显示/隐藏功能,以pretty多的EL用NG-秀=myModelName。在官方文档他们实现这一目标使用复选框。

问:
您可以使用NG-秀上选择的选择吗?我想显示/隐藏根据所选择的选项不同的ELS。

例如

 <选择NG模型=myDropDown>
      <期权价值=一>的One< /选项>
      <期权价值=两化>二< /选项>
      <期权价值=三>三< /选项>
< /选择><输入NG秀=myDropDown ='二'类型=文本>


解决方案

您被关闭,你会想在这里使用==这样的:

 <输入NG秀=myDropDown =='二'类型=文本>

请参阅这个提琴一个例子。

It's fairly straightforward. You can easily give show/hide functionality to pretty much any el using ng-show="myModelName". In the official documentation they achieve this using a checkbox.

Question: Can you use ng-show on a select option? I want to show/hide different els depending on the option selected.

e.g.

<select ng-model="myDropDown">
      <option value="one">One</option>
      <option value="two">Two</option>
      <option value="three">Three</option>
</select>

<input ng-show="myDropDown='two'" type="text">

解决方案

You were close you will want to use == here like this:

<input ng-show="myDropDown=='two'" type="text">

See this fiddle for an example.

这篇关于结合NG-秀在AngularJS一个选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆