[英]How to display list of checkboxes on button click in angularjs?
I am referring to this fiddle http://jsfiddle.net/9HXzW/55/ which is written using Jquery. 我指的是使用Jquery编写的这个小提琴http://jsfiddle.net/9HXzW/55/ 。
The code in HTML is, HTML中的代码是,
<div id="right-column-sidebar">
<ol>
<li><input type="checkbox"/>Check box 1</li>
<li><input type="checkbox"/>Check box 2</li>
<li><input type="checkbox"/>Check box 3</li>
<li><input type="checkbox"/>Check box 4</li>
<li><input type="checkbox"/>Check box 5</li>
</ol>
</div>
<a class="button" href="#"><span>Show Check Box</span></a>
and the jquery is, 而jquery是,
$('div#right-column-sidebar ol li:gt(0)').hide();
$('a.button').on("click", function() {
$('div#right-column-sidebar ol li:gt(0)').slideToggle();
});
I want the functionality in angularjs where on clicking a button, the button should toggle and display a list of checkboxes. 我想要angularjs中的功能,在单击按钮时,该按钮应切换并显示复选框列表。 What changes should i make in the fiddle ? 我应该在小提琴里做些什么改变?
On click of button just toogle the value of displayCheckBox
. 点击按钮只需显示displayCheckBox
的值。 Rest will be handled by angularjs 休息将由angularjs处理
<div ng-show="displayCheckBox">
<ol>
<li><input type="checkbox"/>Check box 1</li>
<li><input type="checkbox"/>Check box 2</li>
<li><input type="checkbox"/>Check box 3</li>
<li><input type="checkbox"/>Check box 4</li>
<li><input type="checkbox"/>Check box 5</li>
</ol>
</div>
<a class="button" href="#" ng-click="displayCheckBox=!displayCheckBox"><span>Show Check Box</span></a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.