F
F
Friend2016-10-16 02:21:58
Angular
Friend, 2016-10-16 02:21:58

How to set checkbox to false when hidden via data-ng-show?

I have a sorting that I control the checkbox myself.
If you hide the checkbox using data-ng-show, then the checkbox remains and sorting continues according to the criterion that was on it. How to uncheck the checkbox when hiding?

<input type="checkbox" data-ng-model='kat' data-ng-true-value='1'/> Первый<br>
<input type="checkbox" data-ng-model='kat' data-ng-true-value='2'/> Второй<br>
<input type="checkbox"  data-ng-model='search.w' data-ng-true-value='К Первому' data-ng-false-value='' data-ng-show="kat == 1" />К Первому<br>
<input type="checkbox" data-ng-model='search.p' data-ng-true-value='К Второму' data-ng-false-value='' data-ng-show="kat == 2"  />К Второму<br>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Friend, 2016-10-16
@Tiran_94

I used Angularjs 1.0.8 and not everything worked there that I tried, installed 1.5.8 and ng-if worked for me, and I was also able to write conditions in ng-change. I have used "Ternary Conditional Operation" for conditions in ng-change.
Here's what happened:

<input type="checkbox" ng-model='uoper' ng-true-value="1" ng-false-value="0" ng-change="one=two=(uoper==1)?undefined:undefined" /> Снять <br>
<span ng-show="!uoper">
<input type="checkbox" ng-model='one' /> Первый<br>
<input type="checkbox" ng-model='two' /> Второй <br>
</span>

one=two=(uoper==1)?undefined:undefined here I assigned one and two undefined in both cases, so I uncheck and clear the model, and already in the span I hide 2 checkboxes when 'Uncheck' is ticked
How to then so

_
_ _, 2016-10-16
@AMar4enko

Toaster-driven development? You are asking the fourth question on checkboxes with this. Read the documentation already, about ng-model in particular

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question