paolodm/angular-selectize — pull request #5 by RossRogers (2014-04-25 17:36:56+00:00)
Title: React to `$scope` field changes?

Hello Eugene,

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 `` 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`](https://docs.angularjs.org/guide/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](https://github.com/brianreavis/selectize.js/blob/master/docs/usage.md#options)

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?

- Ross