[英]Calendar uncheck checkbox not working
I'm trying to implement checkboxes in order to select days. 我正在尝试实施复选框以选择日期。 I can add the event when the checkbox is selected using
ng-click="addEvent()"
. 当使用
ng-click="addEvent()"
选中复选框时,可以添加事件。 However, when it gets clicked again, the ng-click
runs again, adding the same event again. 但是,当再次
ng-click
它时, ng-click
再次运行,再次添加相同的事件。
How can I make it so when the checkbox is uncheck, that it removes event from calendar? 如何取消选中此复选框,以便从日历中删除事件?
Here is my code: 这是我的代码:
<label ng-repeat="day in days"> <input type="checkbox" checklist-model="days" checklist-value="day" ng-click="addEvent(day, exercise)">{{ day.text }} </label>
If you can use jQuery try this: 如果可以使用jQuery,请尝试以下操作:
$( 'input' ).change(function() {
if($( 'input' ).prop( 'checked' )) {
addEvent();
}
}
Although you should give a id
to the input. 尽管您应该给输入一个
id
。 Then just use (when id is "input-1") $(#input-1).prop('checked')
inside the if statement condition 然后只需在if语句条件内使用(当id为“ input-1”时)
$(#input-1).prop('checked')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.