Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($compile): throw an exception when an attribute is unassigned #6064

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
break;

case '=':
if (optional && !attrs[attrName]) {
return;
if (!attrs[attrName]) {
if (optional) {
return;
}
throw Error('Non-assignable model expression: ' + attrs[attrName]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to use minErr when throwing errors... we may need to create a new error code.

throw $compileMinErr('reqattr',
                      "Attribute '{0}' used with directive '{1}' is not optional!",
                      attrName, newIsolateScopeDirective.name);

+ ' (directive: ' + newIsolateScopeDirective.name + ')');
}
parentGet = $parse(attrs[attrName]);
if (parentGet.literal) {
Expand Down