Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 强制显示。绑定执行_Javascript_Aurelia - Fatal编程技术网

Javascript 强制显示。绑定执行

Javascript 强制显示。绑定执行,javascript,aurelia,Javascript,Aurelia,我有一个包含数据的表,当从另一个视图触发事件时,我希望view检查show.bind语句。问题是事件没有更改当前视图中的任何数据 foo.html: <tr repeat.for="entity of viewData.entities"> ... <p if.bind="$parent.canBeRemoved(entity.id)"> canBeRemoved </p> ... </tr> ... 坎伯

我有一个包含数据的表,当从另一个视图触发事件时,我希望view检查show.bind语句。问题是事件没有更改当前视图中的任何数据

foo.html:

 <tr repeat.for="entity of viewData.entities">
  ...
    <p if.bind="$parent.canBeRemoved(entity.id)">
     canBeRemoved
    </p>
 ...
 </tr>

...

坎伯雷

...

我正在使用EventAggregator接收事件,我希望它强制刷新阵列。可能吗?

您可以使用getter函数。例如:

JS

HTML


...

坎伯雷

...
使用
信号
绑定行为 处理此问题的最佳方法是通过信号绑定行为发送信号

template.html

<tr repeat.for="entity of viewData.entities">
  ...
  <p if.bind="$parent.canBeRemoved(entity.id) & signal:'update-view'">
    canBeRemoved
  </p>
  ...
</tr>

这正是我想要的,效果很好。谢谢:)现在从“aurelia模板资源”导入{BindingSignaler};不要拒绝编辑人员,
BindingSignaler
已按kernowcode所述移动,答案应相应更新。
 <tr repeat.for="entity of viewData.entities">
  ...
    <p if.bind="entity.canBeRemoved">
     canBeRemoved
    </p>
 ...
 </tr>
<tr repeat.for="entity of viewData.entities">
  ...
  <p if.bind="$parent.canBeRemoved(entity.id) & signal:'update-view'">
    canBeRemoved
  </p>
  ...
</tr>
import {BindingSignaler} from 'aurelia-templating-resources';

// grab a reference to the signaler
constructor(signaler: BindingSignaler) {
    this.signaler = signaler;
}

// and fire the signal event bound in your view
// whenever the event is handled
respondToEvent(event) {
    // do eventy things
    this.signaler.signal('update-view');
}