1

I am newbie in angular so please keep it in mind. I want to create dynamically some items. In my example item has id and name. Items should not have the same names within scope. Moreover items should not have the same name as items already stored in db. I looked for some kind of ng-remote but I didn't find any which would fulfill my needs. So I created my own async Validator. Here is simple example:

plnkr.co/edit/yEXUnEjd6JC7bFOOSErC?p=preview

Everything works great in simple scenario: 1. user creates first item with name "Test" 2. User creates second item and try to set name as Test then validation occurs. User change the second name as test2. Everything is fine.

BUT. Take a look into second scenario: 1. user creates first item with name "Test" 2. User creates second item and try to set name as Test then validation occurs. 3. User leave the second item and change the first one to "Test2". Validation is still visible because angular validate only item which changed.

So I need to ask how to resolve this kind of issue? I thought that maybe during submit I would rerun validation for each field. But I don't know how. Is there any other ideas?

I spent a lot of time trying to resolve this issue and I couldn't do that.

Marek
  • 193
  • 1
  • 2
  • 11

0 Answers0