Ember TextField valueBinding with dynamic property

前端 未结 3 1479
独厮守ぢ
独厮守ぢ 2020-12-09 23:34

I\'m trying to write a generic view that handles custom fields in my app, but I\'m having a hard time getting this to work. Here\'s the scenario - I have a fieldDef

3条回答
  •  遥遥无期
    2020-12-09 23:56

    You can bind input values with dynamic keys(variables) of objects with help of mut helper now.

    https://guides.emberjs.com/v2.6.0/templates/input-helpers/#toc_binding-dynamic-attribute

    You can access it like this,

    var Object = {};
    var key = "firstName";
    

    We can bind key in input helper like this,

    {{input value=(mut (get Object key))}}
    
    {{Object.firstName}} // Prints the dynamic value in textbox
    

提交回复
热议问题