Ember: 在form-element中添加条件显示字段内容
Ember: Add conditions in form-element to display field contents
如何在 Ember 模板中添加条件。
我要实现的就是这样的条件
if(modalForAdd == true) // if modalForAdd is true then set the model or the property of each input textfield to blank
{
{{bs-form-element controlType="text" label="Quantity" property=""}}
}
else
{
{{bs-form-element controlType="text" label="Quantity" property="model.quantity"}}
}
这是我的模板代码
{{#bs-modal open=openModalForDetails title="Add new Order" body=false footer=false}}
{{#bs-modal-body}}
{{#bs-form model=this action=(action "SaveNewOrder" model "this")}}
{{bs-form-element controlType="text" label="Item SKU" property="model.item" id="item"}}
{{bs-form-element controlType="text" label="Quantity" property="model.quantity" id="quantity"}}
{{bs-form-element controlType="text" label="Description" property="model.description" id="description"}}
{{bs-form-element controlType="text" label="Discount" property="model.discount" id="discount"}}
{{bs-form-element controlType="text" label="Coupon" property="model.coupon" id="coupon"}}
{{bs-form-element controlType="text" label="Price" property="model.price" id="price"}}
{{/bs-form}}
{{/bs-modal-body}}
{{bs-modal-footer closeTitle="Cancel" submitTitle="Add"}}
{{/bs-modal}}
你试过Ember.js条件吗?
{{#if modalForAdd}}
{{bs-form-element controlType="text" label="Quantity" property=""}}
{{else}}
{{bs-form-element controlType="text" label="Quantity" property="model.quantity"}}
{{/if}}
可以在此处找到更多信息https://guides.emberjs.com/v1.10.0/templates/conditionals/
if
助手有一个 inline version 可以用作子表达式。
你可以这样做:
{{bs-form-element controlType="text" label="Quantity" property=(if modalForAdd "" "model.quantity")}}
如何在 Ember 模板中添加条件。 我要实现的就是这样的条件
if(modalForAdd == true) // if modalForAdd is true then set the model or the property of each input textfield to blank
{
{{bs-form-element controlType="text" label="Quantity" property=""}}
}
else
{
{{bs-form-element controlType="text" label="Quantity" property="model.quantity"}}
}
这是我的模板代码
{{#bs-modal open=openModalForDetails title="Add new Order" body=false footer=false}}
{{#bs-modal-body}}
{{#bs-form model=this action=(action "SaveNewOrder" model "this")}}
{{bs-form-element controlType="text" label="Item SKU" property="model.item" id="item"}}
{{bs-form-element controlType="text" label="Quantity" property="model.quantity" id="quantity"}}
{{bs-form-element controlType="text" label="Description" property="model.description" id="description"}}
{{bs-form-element controlType="text" label="Discount" property="model.discount" id="discount"}}
{{bs-form-element controlType="text" label="Coupon" property="model.coupon" id="coupon"}}
{{bs-form-element controlType="text" label="Price" property="model.price" id="price"}}
{{/bs-form}}
{{/bs-modal-body}}
{{bs-modal-footer closeTitle="Cancel" submitTitle="Add"}}
{{/bs-modal}}
你试过Ember.js条件吗?
{{#if modalForAdd}}
{{bs-form-element controlType="text" label="Quantity" property=""}}
{{else}}
{{bs-form-element controlType="text" label="Quantity" property="model.quantity"}}
{{/if}}
可以在此处找到更多信息https://guides.emberjs.com/v1.10.0/templates/conditionals/
if
助手有一个 inline version 可以用作子表达式。
你可以这样做:
{{bs-form-element controlType="text" label="Quantity" property=(if modalForAdd "" "model.quantity")}}