2013-11-28 21 views
0

我嘗試使用餘燼bind-attr將某些屬性傳遞給輸入字段。添加requierd到ember.js中的bind-attr?

<input {{bind-attr requierd="field.requierd" type="field.type" name="field.key" id="field.name"}} /> 

幾乎所有需要的工作。我假設燼具有某種允許的屬性列表。可以添加新的嗎?

有人有類似的問題,雖然TextField,似乎並不是我應該擴展的東西。

App.TextField = Ember.TextField.extend({ 
    attributeBindings: ['required'], 
    required:   null 
}); 

回答

1

你有合適的火車人。參考文獻DOCS here。由於使用裸輸入標籤,所以出了問題。使用擴展text-field component或更多更清潔的方式是將其註冊爲一個幫手,並在哈佛商學院

App.TextField = Em.TextField.extend({ 
    attributeBindings: ['required'] 
}); 

Em.Handlebars.helper('input',App.TextField); 

對上更新

Demo Working

+0

使用它,花花公子!;) – Himmators

+0

這工作,雖然我收到錯誤「斷言失敗:您試圖註冊一個名爲'input'的組件,但組件名稱必須包含' - '」 – Himmators

+0

(您也是如此;)) – Himmators