mercredi 15 avril 2015

How to create a helper with bounded property in Ember-CLI?

I am using Ember-CLI (2.0.0) recently and am testing a simple Helper built from the generator.


The Helper does its job but the problem is that the variable used is not bounded and when its value changes not reflected in the UI.


The helper is a get property to which you pass a property name and an object and returns the value of that property, this the code



// get-property.js
import Ember from 'ember';

export function getProperty(context) {
var name = context[0];
var data = context[1];
return data.get(name);
}

export default Ember.HTMLBars.makeBoundHelper(getProperty);


And this is the use



//some hbs
{{#each item in filteredList}}
{{get-property 'name' item}}
{{/each}}


I hope someone can give me some direction where investigate or learn.


Thanks in advance





Aucun commentaire:

Enregistrer un commentaire