我尝试使用dxi-item创建dxForm,这将填满dxSelectBox:
第一个示例deos不起作用,只有当我将项目设置为string []数组,但object [] array deos不起作用时才有效吗?我还尝试在editorOptions中设置dataSource。
示例:
<dxi-item [label]="{text: 'Test'}" editorType="dxSelectBox" [editorOptions]="{ dataSource:testList, items:testList, displayExpr:'name', valueExpr:'id', placeholder:'Select Test' }">
<dxi-validation-rule type="required" message="Test is required"></dxi-validation-rule>
</dxi-item>
即使我设置了dataSource但没有运气?使用object []数组的第二个例子很好但我想使用dxi-item指令:
<div class="dx-field">
<div class="dx-field-label">Test usage</div>
<div class="dx-field-value">
<dx-select-box
[dataSource]="testList"
displayExpr="name"
valueExpr="id"
[value]=""
></dx-select-box>
</div>
</div>
答案 0 :(得分:0)
以这种方式绑定,以便Angular绑定起作用:
<dxi-item [label]="{text: 'Test'}" editorType="dxSelectBox" [editorOptions]="selectBoxOptions">
<dxi-validation-rule type="required" message="Test is required"></dxi-validation-rule>
</dxi-item>
selectBoxOptions = { dataSource:[], displayExpr:'name', valueExpr:'id', placeholder:'Select Test' };
http.get(URL).then(data => {
this.selectBoxOptions = { dataSource:data, displayExpr:'name', valueExpr:'id', placeholder:'Select Test' }
});