4

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?

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the notes on $eval and $parse, useful. I would be interested in an explanation to why "ng-model and isolate scopes do not mix", but I'll accept this as I understand that might be an implementation detail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.