1

how to Checked value from $index base. suppose in textboxStart Index and TextboxEnd . when user enter Start index 5 and End Index 10 , checkbox automatically checked, from 5 To 10 Index. please help me

<tr ng-repeat="item in MyList">
    <td>{{$index}}</td>
    <td>
        <label class="mdl-checkbox mdl-js-checkbox" for="checkbox33">
            <input autocomplete="off" ng-model="item.checked" 
                   type="checkbox" id="checkbox33"
                   class="mdl-checkbox__input" unchecked>
            {{CheckItems()}}
        </label>
    <td>{{item.Name}}</td>
    <td>{{item.PilgrimID}}</td>
    <td>{{item.GroupName}}</td>
    <td>{{item.PassportNo}}</td>                      
    <td>{{item.Gender}}</td>
    <td>{{item.SubAgentName}}</td>  

enter image description here

3 Answers 3

1

Use the ng-change directive to specify an update function:

<div>Input Start
  <input ng-model="inputStart" ng-change="updateSelections(inputStart,inputEnd)" />
</div>
<div>Input End
  <input ng-model="inputEnd" ng-change="updateSelections(inputStart,inputEnd)" />
</div>

Then update the selections:

$scope.updateSelections = function(iStart, iEnd) {
    $scope.MyList.forEach((x,index)=>item.checked = (iStart<=index && index<=iEnd));
};
Sign up to request clarification or add additional context in comments.

Comments

0

just push the selected values in an array , selectedItemIndexes like ng-checked="selectedItemIndexes.includes($index)"

https://stackblitz.com/edit/angularjs-snavdn

1 Comment

i want to inputstart = 1 and inputEnd = 7 . then automatically 1 to 7 index values are checked
0

you can do it by adding one property like ItemIndex in your ItemList model, and by putting input box with display none you can get index value in ItemList and can do what you want from javascript side,

<td><input type="text" style="display:none;" ng-model="item.ItemIndex"
           ng-value="$index"/>{{$index}}
</td>

Comments

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.