Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Adding custom validation directive removes all selected values #981

Open
martinoss opened this issue Jun 2, 2015 · 3 comments
Open

Adding custom validation directive removes all selected values #981

martinoss opened this issue Jun 2, 2015 · 3 comments

Comments

@martinoss
Copy link

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

@awerlang
Copy link
Contributor

awerlang commented Aug 7, 2015

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

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

@meyerds
Copy link
Contributor

meyerds commented Dec 11, 2015

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
Copy link
Contributor

meyerds commented Dec 16, 2015

I've submitted a pull request for this issue: #1359

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants