oi.select
oi.select copied to clipboard
Is there a way to change select-options at runtime?
For example, the search and dropdown filters?
I have tried almost everything. It seems that options are used only at init-time and there is no way to change them afterwards?
Is there a way to achieve this?
I used ng-keyup to dynamically load options from database as the user types in the keys
<oi-select oi-options="item.name for item in diagnosisList track by item.id" ng-model="model.selectedDiagnosis" ng-keyup="updateDiagnosisList($event);" multiple placeholder="Select"></oi-select>
`$scope.updateDiagnosisList = function($event){ if($event.keyCode != 37 && $event.keyCode != 38 && $event.keyCode != 39 && $event.keyCode != 40 && $event.keyCode != 13 && $event.keyCode != 8 && $event.target.value != ''){ console.log($event.target.value); url='./api/getDiagnosis?diagCodeLike=' + $event.target.value; console.log(url); console.log($event.keyCode);
$http.get(url).then(function(response) { $scope.diagnosisList = response.data; });
}
}`
Hey @ananth17 , thanks for your response. But I didn't mean the options on the dropdown list, but the options used to initialize the control. Like the filters used to render the options and the selected item.
To change the options on the list, I just do it like this: <oi-select oi-options="it.title for it in ctrl.loadItems($query, $selectedAs) track by it.id" ng-model="ctrl.the_item"></oi-select>
.. and then in the controler there is the loadItems function:
vm.loadItems = function(query, selectedAs) {
return dataService.getItems(query);
};