AngularJS NG-显示一个条件多元素 [英] AngularJS ng-show one condition with multiple elements
本文介绍了AngularJS NG-显示一个条件多元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有三个div的与NG点击。他们的段落有一个NG-显示,evaulatesSHOWME。
I have three divs with an ng-click with a "showMe" boolean. Their paragraphs have an ng-show that evaulates "showMe".
我的问题是,我该如何使用一个条件,以显示在DIV我点击段落?换句话说,如果我点击第一个div,我应该只看到1,2和3parapgraphs应该留下隐患。 NG-重复不是这项工作的一个选项。
My question is, how can I use one condition to show the paragraph on the div I click? In other words, if I click the first div, I should only see "1", the "2" and "3" parapgraphs should stay hidden. ng-repeat is not an option for this exercise.
下面是一个JSBin:
Here's a JSBin:
http://jsbin.com/kiwicipabago/1/edit
感谢您。
推荐答案
您可以这样做:
<div ng-app="app">
<div ng-controller="AppCtrl">
<div class="box" ng-click="showMe = 1">
<p ng-show="showMe ==1">1</p>
</div>
<div class="box" ng-click="showMe = 2">
<p ng-show="showMe==2">2</p>
</div>
<div class="box" ng-click="showMe = 3">
<p ng-show="showMe ==3">3</p>
</div>
</div>
这篇关于AngularJS NG-显示一个条件多元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文