‘=?’的含义是什么?在angularJS指令隔离范围声明?
问号在等号后有特殊意义吗?即:
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]); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |