Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to change select-options at runtime? #101

Open
adlh opened this issue Jul 14, 2016 · 2 comments
Open

Is there a way to change select-options at runtime? #101

adlh opened this issue Jul 14, 2016 · 2 comments

Comments

@adlh
Copy link

adlh commented Jul 14, 2016

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?

@ananth17
Copy link

ananth17 commented Oct 22, 2016

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; });
     }

 }`

@adlh
Copy link
Author

adlh commented Oct 22, 2016

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);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants