【发布时间】:2015-08-16 12:00:01
【问题描述】:
在包含ngf-drop 使用的文件属性的模型上添加$watch 并将objectEquality 设置为true 时会出现TypeError: Illegal invocation。
也如报告here。
我如何$watch 模型而不出现此错误?
【问题讨论】:
在包含ngf-drop 使用的文件属性的模型上添加$watch 并将objectEquality 设置为true 时会出现TypeError: Illegal invocation。
也如报告here。
我如何$watch 模型而不出现此错误?
【问题讨论】:
我不得不说,永远不要尝试深入观察一个复杂的对象,这意味着:
$scope.$watch('aComplexObject', function(newVal, oldVal) {
// ...
}, true); // <<< this 'true' may cause the error.
【讨论】:
无需为文件使用单独的范围变量即可解决。
我没有使用$watch 模型,而是$watched 一个函数,它返回Json.stringify(model) -- 和objectEquality true。
它有效,并且似乎不会以用户可见的方式损害性能。
【讨论】: