當我嘗試將Ember綁定或計算屬性傳遞給自定義Handlebars助手時,助手將接收字符串而不是值。我如何獲得幫助者的價值?您如何製作瞭解Ember綁定的Handlebars助手?
模板:
{{my_helper my.binding}}
助手接收 「my.binding」,而不是對應的值。
當我嘗試將Ember綁定或計算屬性傳遞給自定義Handlebars助手時,助手將接收字符串而不是值。我如何獲得幫助者的價值?您如何製作瞭解Ember綁定的Handlebars助手?
模板:
{{my_helper my.binding}}
助手接收 「my.binding」,而不是對應的值。
前幾天一個push on the master解決了這個問題: 使用Ember.Handlebars.registerBoundHelper。
Ember.Handlebars.registerBoundHelper('myHelper',
function(myBinding, options) {
return myDealWith(myBinding);
}
);
您必須使用Ember.getPath以獲取幫助方法中的值。
請參閱該文檔http://emberjs.com/documentation/#toc_writing-custom-helpers
是否有我應該使用'Ember.getPath(this,property)'this.getPath(property)''的原因? – hekevintran
如果你曾經期望'this'不是'Ember.Object',你會想要使用'Ember.getPath'。 – ebryn
......也就是說,大部分時間你可以(也應該)使用'this.getPath'。 –
您無法使用塊對象。 – iConnor