Custom validation directive with isolated scope in angularjs?

Take a look at the following JSFiddle: http://jsfiddle.net/AaQtz/21/ . As you can see, a regular check is performed and when the value is considered valid, it is updated in the model.

However, when I add scope: {}, to the directive, the model no longer receives updates when this value is valid. Why is this? This behavior makes it very difficult to build a directive that checks the field against other fields (fields that I would like to pass using the scope, for example scope: { somefield: '=' }, ). JSFiddle shows the problem: http://jsfiddle.net/JYUmT/1/ .

Can anyone explain this?

+4
source share
1 answer

ng-model and isolate areas do not mix: Can I use an ng model with an isolated area?

Use $ eval or $ parse to pass / check attributes in a directive that does not use the allocation area: fooobar.com/questions/21524 / ...

+3
source

Source: https://habr.com/ru/post/1491868/


All Articles