如何设置DevExtreme DxCombobox的值?

时间:2016-06-22 01:31:41

标签: angularjs devextreme

如何从javascript代码设置Combobox'值(SelectedBox)?

组件演示

http://js.devexpress.com/Demos/WidgetsGallery/#demo/editors-select_box-search_and_editing/angular/generic/light.compact

我需要从javascript代码设置值,我使用AngularJS!

来自组件的api我没看到如何设置它!

http://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxSelectBox/?version=15_2

1 个答案:

答案 0 :(得分:0)

dxSelectBox API中有value选项。好吧,只需设置此选项即可。如果要对selectbox值使用双向绑定,请使用bindingOptions对象。

HTML

<div dx-select-box="{dataSource: data, bindingOptions: { value: 'selectedItem' } }"></div>

JS

myApp.controller("myCtrl", function($scope) {
    $scope.data = [/* your data */];
    $scope.selectedItem = $scope.data[0];
});

我已经创建了小样本here