Skip to content Skip to sidebar Skip to footer

Force Show.bind Execution

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 curr

Solution 1:

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 signalerconstructor(signaler: BindingSignaler) {
    this.signaler = signaler;
}

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

Solution 2:

You could use a getter function. For instance:

JS

export class Entity {

    //@computedFrom('property1', 'property2')
    get canBeRemoved() {
       //your magic here
       //return true or false;
    }
}

HTML

<trrepeat.for="entity of viewData.entities">
  ...
    <pif.bind="entity.canBeRemoved">
     canBeRemoved
    </p>
 ...
 </tr>

Post a Comment for "Force Show.bind Execution"