0

I have a list of vochers that are shown with ng-repeat from a WebService, and each vocher has an associated checkbox, when I check a specific checkbox the price of the vocher is deduct of the Total Price, the problem in question is: " once the Total price is 0 I have to disable the unchecked checkbox" at the moment I can disable them all but I want to keep the checked checkboxes enable so I can uncheck them again.

HTML:

<div class="item" ng-class="{active:!$index}" ng-repeat="slide in MesAvoirs | limitTo: slideLength track by $index">
    <div class="mes_avoires" ng-repeat="a in MesAvoirs  | startFrom: ($index*5) | limitTo: 5">
        <input class="mes_avoires_checkbox" type="checkbox" ng-model="check" ng-change="avoirPrixCal($index,check,a)" id="chBx-{{$index}}" ng-disabled="uncheckVar" />
        <div class="left_av">
            <em>{{"MonProfilMesAvoirs.Num_Avoir" | translate}} {{a.NumeroAvoir}}</em>
            <strong>{{a.Montant}} {{"Globale.Devise" | translate}}</strong>
        </div>
        <div class="right_av">
            <em translate="MonProfilMesAvoirs.Valide_till"></em>
            <strong>{{a.DateValiditeJ }} {{a.DateValiditeM}} {{a.DateValiditeY}}</strong>
        </div>
    </div>
</div>

1 Answer 1

1

If i understand your question you want to disable unchecked checkbox when the total price is equal to 0.

Why do you don't used a model to get the status of the checkbox (checked or unchecked) and test something like :

<input type="checkbox" ng-model="yourCtrl.checked[your_checkbox_number]" ng-disable="(yourCtrl.totalPrice <= 0 && !yourCtrl.checked[your_checkbox_number])/>
Sign up to request clarification or add additional context in comments.

3 Comments

It works but it disable all the checkbox even the checked ones, I need a solution to disable only the unchecked ones if you have one please suggest it
yes you will need to have one variable by checkbox in your ng-model. one way is to used an array and set the model to the index in the array that match to your checkbox number ng-model="yourCtrl.checked[your_checkbox_number]" ng-disable="(yourCtrl.totalPrice <= 0 && !yourCtrl.checked[your_checkbox_number])
It Worked Thakns Jerely : <input class="mes_avoires_checkbox" type="checkbox" ng-model="check" ng-change="avoirPrixCal($index,check,a)" id="chBx-{{$index}}" ng-disabled="(Topay <= 0 && !check)" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.