angularjs-dropdown-multiselect icon indicating copy to clipboard operation
angularjs-dropdown-multiselect copied to clipboard

Make directive compatible with NgModelController so it works with forms

Open yangchristian opened this issue 10 years ago • 4 comments

Hi there,

I wanted your multiselect to be able to take advantage of built-in Angular forms functionality like $dirty and $pristine states, validation, and whatnot, so I made your directive compatible with NgModelController (see the "Implementing custom form controls" section of the Angular guide). This change also makes your component compatible with, say, angular-unsavedChanges.

It's (hopefully) fairly straightforward, requiring ngModel and using NgModelController.$viewValue and NgModelController.$setViewValue() instead of selectedModel .

However, it is a _breaking_ change in that all consumers must set the ng-model attribute _instead_ of the current selected-model attribute (which is removed). This behavior is consistent with standard form Angular controls, so hopefully makes for more standard usage.

Thanks!

yangchristian avatar Apr 08 '15 02:04 yangchristian

Just plain awesome ! Thanks a lot for sharing this. kbjp

smoothello avatar May 06 '15 09:05 smoothello

Thanks for the kind words @kbjp!

yangchristian avatar May 06 '15 19:05 yangchristian

Are there any plans to merge this PR?

slnowak avatar Jun 18 '15 15:06 slnowak

:+1:

preston avatar Jun 23 '15 16:06 preston