强制执行show.bind [英] Force show.bind execution

查看:105
本文介绍了强制执行show.bind的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含数据的表,当从另一个视图激发该事件时,我希望视图检查show.bind语句.问题在于该事件不会更改当前视图中的任何数据.

I have a table with data, and i want view to check show.bind statement when the event is fired from another view. The problem is that the event is not changing any data in the current view.

foo.html:

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

我正在使用EventAggregator接收事件,并且希望它强制刷新数组.有可能吗?

I'm receiving the event with EventAggregator and i want it to force refresh on the array. Is it possible?

推荐答案

使用signal绑定行为

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

Use the signal binding behavior

The best way to handle this is to send a signal through the signal binding behavior.

template.html

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

viewModel.ts

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');
}

这篇关于强制执行show.bind的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆