ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

Adding custom validation directive removes all selected values

Open martinoss opened this issue 11 years ago • 3 comments

I added a custom validation directive to ui-select that validates all selected items to make sure each item has a valid email property.

But after validation returns falsy, all selected items gets lost: http://plnkr.co/edit/gW52dvUjMx4ydHEaHa4a?p=preview

martinoss avatar Jun 02 '15 13:06 martinoss

Add ng-model-options="{allowInvalid: true}" next to ng-model.

Reference: https://docs.angularjs.org/api/ng/directive/ngModelOptions

awerlang avatar Aug 07 '15 03:08 awerlang

I'm also in need of a fix for this issue - and allowing invalid won't work in my situation. I'm researching the right way to handle this, if I find the answer I'll at minimum post here, or try to submit a pull request.

My belief is that the "Angular way" is for the selected items to continue to display in DOM while the ngModelController's model value is undefined and the invalid flag is set. That behavior is consistent with built-in inputs in Angular.

meyerds avatar Dec 11 '15 22:12 meyerds

I've submitted a pull request for this issue: https://github.com/angular-ui/ui-select/pull/1359

meyerds avatar Dec 16 '15 21:12 meyerds