This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
directives that have '=' binding, changing scope value causes error if not specified(optional) #1435
Closed
Description
If I have a directive with a scope definition, and setting a value in the scope:
directive('some', function () {
return {
scope: {optionalValue: '='},
bind: function(scope) {
scope.optionalValue = something;
}
}
}
And create it like
<some />
With optionalValue not specified, it yields the NON_ASSIGNABLE_MODEL_EXPRESSION error.
But I'd expect it to work in this case.
This could be solved in the "scope mode parser" by simply not applying the binding:
case '=': {
if (attrs[attrName] == null) {
return;
}
...
Or is this intentionally? If so, maybe add a new symbol like '~' for optional attributes?
(just realized that I opened essentially the same issue 3 months ago: #1131)