indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

Feature request: ngChange alike attribute #9

Closed stevenvegt closed 8 years ago

stevenvegt commented 8 years ago

When someone changes the selection, I need to do some work. Currently I've implemented this by a watch on the model, but this is not very elegant. Most angular input directives now support ngChange to prevent this expansive method. Do you think angular-selector will benefit from such a callback method?

Thanks for this nice component!

indrimuska commented 8 years ago

Mmhh interesting point, I think it could be an easy-to-implement feature request if this will help someone. I also think that Angular Selector needs some little optimizations but I don't have so much spare time to do that. Any PR will be accepted! :smile:

Anyway I will look into this in the next few days. :)

indrimuska commented 8 years ago

Hi @stevenvegt, With the latest release you can have your onChange callback by providing change attribute to your elements like this:

<select selector
        model="browser"
        options="browsers"
        label-attr="name"
        change="myCallback(newValue, oldValue)"></select>

Hope this could help you! :)

stevenvegt commented 8 years ago

That's awesome! Thanks :+1: