Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

If already not there, add possibility to $watch for $select.search value #235

Closed
developer10 opened this issue Sep 29, 2014 · 2 comments
Closed

Comments

@developer10
Copy link

I need to query an API for list of suggestions as the user is typing (initially my selectbox is empty). I believe I should be able to $watch the entered value. There's $select.search used as a filter so I think I should $watch this value in order to trigger the API call.

Is such a possibility already there? If yes, how do I achieve that?

@developer10
Copy link
Author

For the time being I have "solved" this by placing an $emit inside the ui-select directive (obviously, I'm using it locally, not from a CDN) and then listening for an event in my controller.

Since the event is placed within a $watch function for $select.search, the event is fired whenever the value changes.

I need to somehow override the directive itself so I'm able to keep the event outside it, to be safe for future updates as well as for being able to use CDN version.

@dimirc
Copy link
Contributor

dimirc commented Oct 8, 2014

You could use your own function to populate the choices based on $select.search. Check this comment. Also the first at the demo you can check the first example that is calling an external API

@dimirc dimirc closed this as completed Oct 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants