imevro / ng-selectize

AngularJS directive for Selectize.js
39 stars 10 forks source link

Hello Eugene, #1

Closed RossRogers closed 10 years ago

RossRogers commented 10 years ago

You don't seem to have either an issues or a discussion page for your ng-selectize directive, so I'm communicating with you through a pull request..

My base <select> object is getting populated with data from an AngularJS $scope attribute. The directive that you currently have doesn't respond to data updates or have a way of getting hooked into $scope field changes.

I added a new parameter to the directive called selectize-data, and quoting my README doc changes:

selectize-data - tells the AngularJS selectize directive to listen for any changes to the specified data array in the current $scope and then to update the options in the selectize widget with any new options in the updated array.

selectize.js will grab the fields in each element of the array according to the JSON labelField and valueField parameters that are the values of the element's selectize attribute. Defaults for those parameters may be seen in the selectize.js options documentation

Now, when you specify selectize-data, it will add at $watch on that field of the scope parameter and then update the selectize instance.

Unfortunately, I don't know CoffeeScript yet and I'm an amateur javascript'er.

What do you think about such a change? Is it already supported and I'm using your directive incorrectly? Should I do something else to acheive this? Or is this a reasonable enhancement to the directive? Are the parameter names ok?