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 it possible to add support for custom query function like the select2? #30

Closed
faxal opened this Issue Feb 27, 2014 · 6 comments

Comments

Projects
None yet
5 participants
@faxal

faxal commented Feb 27, 2014

No description provided.

@ProLoser

This comment has been minimized.

Show comment
Hide comment
@ProLoser

ProLoser Feb 27, 2014

Member

Based on what you enter? I was thinking about this and how ui-bootstrap implements it. I was hoping that we could just let you access and $watch $select.search and you would update the filter or items array yourself.

Member

ProLoser commented Feb 27, 2014

Based on what you enter? I was thinking about this and how ui-bootstrap implements it. I was hoping that we could just let you access and $watch $select.search and you would update the filter or items array yourself.

@faxal

This comment has been minimized.

Show comment
Hide comment
@faxal

faxal Feb 28, 2014

Yes, that is precisely what I was looking for. I want to filter items list based on what I enter to $select.search. Is it possible to access $select.search ?

Would be great if it was possible to use ng-change

So I could do something like <input ui-select ng-change="update($select.search)" data="items" />

faxal commented Feb 28, 2014

Yes, that is precisely what I was looking for. I want to filter items list based on what I enter to $select.search. Is it possible to access $select.search ?

Would be great if it was possible to use ng-change

So I could do something like <input ui-select ng-change="update($select.search)" data="items" />

@faxal

This comment has been minimized.

Show comment
Hide comment
@faxal

faxal Feb 28, 2014

@ProLoser could you have look at my PR when convenient. I have attached a Plunkr for you to check. It's a very small change. Thanks

faxal commented Feb 28, 2014

@ProLoser could you have look at my PR when convenient. I have attached a Plunkr for you to check. It's a very small change. Thanks

@tkrotoff

This comment has been minimized.

Show comment
Hide comment
@tkrotoff

tkrotoff Mar 25, 2014

Member

Thanks for the pull request and the example.
However I've implemented it in a different way, you can now provide a promise to the "repeat" expression.
Please check the demo.

Member

tkrotoff commented Mar 25, 2014

Thanks for the pull request and the example.
However I've implemented it in a different way, you can now provide a promise to the "repeat" expression.
Please check the demo.

@tkrotoff tkrotoff closed this Mar 25, 2014

@kencaron

This comment has been minimized.

Show comment
Hide comment
@kencaron

kencaron Jun 30, 2014

In case it would help anybody, here is a filter that allows the user to input whatever they want while still having the select options. It has an underscore requirement and is probably woefully inefficient but anyway:

// where items = [{display: 'item 1'},{display: 'item 2'}]

.filter('selectSearch', function() {
    return function(items, input) {
        var displays = _.pluck(items, 'display');
        if (!_.contains(displays, input)) {
            var first = _.first(items);
            if (first && first.custom) {
                first.display = input;
            } else {
                items.unshift({display: input, custom: true});
            }
        }
        return items;
    };
});

kencaron commented Jun 30, 2014

In case it would help anybody, here is a filter that allows the user to input whatever they want while still having the select options. It has an underscore requirement and is probably woefully inefficient but anyway:

// where items = [{display: 'item 1'},{display: 'item 2'}]

.filter('selectSearch', function() {
    return function(items, input) {
        var displays = _.pluck(items, 'display');
        if (!_.contains(displays, input)) {
            var first = _.first(items);
            if (first && first.custom) {
                first.display = input;
            } else {
                items.unshift({display: input, custom: true});
            }
        }
        return items;
    };
});
@VictorioBerra

This comment has been minimized.

Show comment
Hide comment
@VictorioBerra

VictorioBerra Mar 17, 2017

@kencaron That involves filter having a reference to the options globally.

VictorioBerra commented Mar 17, 2017

@kencaron That involves filter having a reference to the options globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment