Polymer 如何链接路径以便在dom repeat中更新结果

Polymer 如何链接路径以便在dom repeat中更新结果,polymer,Polymer,我正在开发预约系统。它基本上由一组聚合物自定义元素组成,排列如下(缩进元素位于元素的模板中,而不是如图所示实际组织) 未显示的是内部的机制,用于更新类型属性。因此,当我使用此机制更新type属性时,可视化表示在元素内会发生更改,但在dom repeat内不会发生更改。我可以检查位于appointents[n]的对象是否已更新,但显示未更新 我想我没有正确地将预订与相应的预约条目联系起来。但是我应该如何做到这一点呢?聚合物没有观察到约会的子属性的变化。 尝试使用以下代码强制数据系统拾取阵列突变:

我正在开发预约系统。它基本上由一组聚合物自定义元素组成,排列如下(缩进元素位于元素的模板中,而不是如图所示实际组织)

未显示的是
内部的机制,用于更新
类型
属性。因此,当我使用此机制更新
type
属性时,可视化表示在
元素内会发生更改,但在dom repeat内不会发生更改。我可以检查位于
appointents[n]
的对象是否已更新,但显示未更新


我想我没有正确地将预订与相应的预约条目联系起来。但是我应该如何做到这一点呢?

聚合物没有观察到
约会的子属性的变化。
尝试使用以下代码强制数据系统拾取阵列突变:

// Force data system to pick up the **array** mutations
var array = this.appointments;
this.appointments= [];
this.appointments= array;
// Force data system to pick up array mutations
var object = this.appointment;
this.appointment= [];
this.appointment= object;
尝试将其添加到代码中

  if (foundAppointment) {
    //found where to insert appointment, so do so
    this.splice(path, j, 0, this.booking);
    this.linkPaths('booking', path + '.' + j);
    this.linkedBooking = true;
    // Force data system to pick up array mutations
    var array = this.appointments;
    this.appointments= [];
    this.appointments= array;
    break;
  }
或使用以下代码强制数据系统拾取对象

// Force data system to pick up the **array** mutations
var array = this.appointments;
this.appointments= [];
this.appointments= array;
// Force data system to pick up array mutations
var object = this.appointment;
this.appointment= [];
this.appointment= object;

我只是猜测问题出在哪里。 聚合物对此有特殊的规定

以下是数组绑定的一个示例:


索引:[[Index]]

首先是这样:[[arrayItem(people.*,index,'First')]]
首先不是这样:[[item.First]]


简化的在线问题示例将有助于更好地理解问题。

尽管我认为您可能大致正确,但dom repeat肯定会对约会数组的子属性进行更改。在我的真实代码中,dom repeat中实际上还有另一个
副本,我可以更新它并更新约会输出。在这种情况下,它不会反映回booking(在显示中,尽管该值是传播的,并且可以看到已在booking inside
副本中使用调试器设置)。我确实在预订上耍了你的把戏,因为我第一次在阶段(ajax调用)中设置它。我编辑了我的初始回复,你可以对对象变异使用相同的把戏。你的解决方案在我实际代码的上下文中逻辑上不太正确,但这种方法是有效的。我实际做的是让观察员了解约会和预订的变化,然后用它们来更新其他元素
<template is="dom-repeat" items="[[first4People(people, people.*)]]"> 
    <div>
        Index: <span>[[index]]</span>
        <br>
        First as this:[[arrayItem(people.*, index, 'first')]]
        <br>
        First not as this: <span>[[item.first]]</span>
   </div>
   <br><br>
</template>