I am using chosen in angularjs.
I created a select as follows. and I need to changes the options dynamically.
<select class="sel-bx" chosen dataload="aListOfSampleIds.length" multiple selecteditm="sampleIdList" ng-model="sampleIdList"
ng-options="sampleIds.sample_id as sampleIds.sample_id
for sampleIds in aListOfSampleIds | unique:'sample_id'" data-placeholder = " " >
</select>
In the directive i wrote
$(".chosen-container").unbind('keyup').bind('keyup',function(e) {
//console.log('sfddf');
var searchStr = $('.chosen-container .search-field input').val();
console.log(searchStr);
if (searchStr.length > 2) {
console.log("Hi");
//Need to change the options in the list here
$rootScope.aListOfSampleIds =['sample_id','llll'];
}
});
How can I do this.
Once when I used chosen, I had to put in my directive following code in order to change it dynamically. Not sure what it means, I didn't investigate, also, not sure if it will resolve your problem, but, you could try and see.