From ca16eacf2515acf9d81a4a6ae6503f3a2a931a8b Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Fri, 31 Jan 2014 00:00:35 +0200 Subject: [PATCH] fix($compile): throw an exception when an attribute is unassigned Documentation states that NON_ASSIGNABLE_MODEL_EXPRESSION exception should be thrown if a two-way attribute doesn't exist. This commit adds a simple test and throws an error if the property is missing. Note that the documentation should probably be updated and a different exception should be thrown using minErr. This commit refers to issue #6060 --- src/ng/compile.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 941b449ad359..100081952020 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -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] + + ' (directive: ' + newIsolateScopeDirective.name + ')'); } parentGet = $parse(attrs[attrName]); if (parentGet.literal) {