I'm planning on displaying a lot of checkboxes to the user so I tried implementing a filter option where the user can search for a specific item they would like to select. I display the list of checkboex with the ng-repeat directive and filter the results based on what the user types.
The problem is that if an option, already checked, gets filtered out, it gets unchecked. How do I prevent this from happening? This is the relevant code
verbSelect.html
<div class="row">
<div class="col-xs-12">
<h3>Select the verbs</h3>
<input type="text" ng-model="filterText" />
</div>
<div class="col-xs-12">
<span ng-repeat="verb in verbArray | filter: filterText">
<label class="checkbox" for="">
<input type="checkbox"/><img src=""/>
</label>
</span>
</div>
</div>
The above code is under this controller:
.controller('verbController', ['$scope', 'verbFactory', function($scope, verbFactory){
//Gets verbs from server
$scope.verbArray = verbFactory.getVerbs().query(
function(response) {
$scope.verbArray = response;
},
function(response) {
$scope.message = "Error: " + response.status + " " + response.statusText;
}
);
//Sotres the array of selected verbs
$scope.selectedVerbs = {};
//Stores how many practice questions the user wants
$scope.howMany = 0;
//Stores what tense of verbs the user wants
$scope.verbTense = "both";
//Stores what form the user wants
$scop.verbVoice = "both"
//Include commands?
$scope.includeCommands = true;
}])
Aucun commentaire:
Enregistrer un commentaire