In my directive I create an isolate scope and assign to the ngModel in code. Here's my isolate scope:
scope: {
ngModel: '=',
value: "=",
placeholder: "@"
}
Inside the link function I assign to scope.ngModel. That works fine if the ng-model attribute is set on the element, but when it's not it raises an error.
Error: Non-assignable model expression: undefined
What's the preferred way to check if the attribute exists? Do I have to do this explicitly with element.hasAttribute or am I doing it completely wrong?
=). You could however optionally?^requirethe model, and have it injected to your link-function as the 4th parameter.