Reputation: 4859
Take a look at the following JSFiddle: http://jsfiddle.net/AaQtz/21/. As you can see, the custom validation runs and when the value is considered valid it is updated in the model.
However, when I add scope: {},
to the directive, the model is no longer receiving updates when the value is valid. Why is this? This behaviour makes it very hard to build a directive that validates a field depending on other fields (fields I would like to pass using the scope, such as scope: { somefield: '=' },
). JSFiddle showing the problem: http://jsfiddle.net/JYUmT/1/.
Can anyone explain this?
Upvotes: 4
Views: 1210
Reputation: 364687
ng-model and isolate scopes do not mix: Can I use ng-model with isolated scope?
Use $eval or $parse to pass/examine attributes in a directive that doesn't use an isolate scope: https://stackoverflow.com/a/15725402/215945
Upvotes: 3