问题:当控制器修改“pages”数组时,计算属性“tnop”不会更新,如下所示:
sections: []
tnop: function()
{
var n = 0;
var sections = this.get('sections');
if (!sections)
return n;
for (var i=0; i < sections.length; i++) {
n += sections[i].pages.length;
}
return n;
}.property('sections.@each.pages.length')
var sections = EM.model.getPath('book.sections');
var aps = EM.model.getPath("ps");
$.each(sections, function(si, section) {
var bp = [];
if (json && json.ia) {
bp = section.get("pages");
var ns = aps[json.ssi];
var lp = ns.get("lp");
var rp = ns.get("rp");
if (rp) {
bp.insertAt(lp.number-1, rp);
bp[lp.number-1] = rp;
}
if (lp) {
bp.insertAt(lp.number-1, lp);
bp[lp.number-1] = lp;
}
}
});
答案 0 :(得分:5)
就目前而言,您无法直接观察@each的深层嵌套路径。相反,您必须使用嵌套的@each代理,如下所示:
属性( '部分。@ each.pages。@ each.length')
答案 1 :(得分:1)
使用以下代码解决了同样的问题:
filters: [],
content: [],
filterFun: function()
{
}.property('content.@each', 'filters.@each').cacheable(),