等问后的问号有特殊含义吗?即:
scope: {foo: '=?'}
上面的意思是“无法解决'foo'时不会引发错误?”
最佳答案
Yes:
它应该在影响范围属性的每个摘要上触发预期的错误:
parentSet = parentGet.assign || function() {
// reset the change, or we will throw this exception on every $digest
lastValue = scope[scopeName] = parentGet(parentScope);
throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + attrs[attrName] +
' (directive: ' + newScopeDirective.name + ')');
};
//...
if (parentValue !== scope[scopeName]) {
// we are out of sync and need to copy
if (parentValue !== lastValue) {
// parent changed and it has precedence
lastValue = scope[scopeName] = parentValue;
} else {
// if the parent can be assigned then do so
parentSet(parentScope, lastValue = scope[scopeName]);
}
}
关于angularjs - angularJS指令隔离范围声明中的 '=?'是什么意思?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20447786/