我知道如何访问所选选项的值,但如果我想访问显示给用户的标签,该怎么办?我希望能够得到两者。我使用了形式,这就是它的样子
vm.InwardLeaseFields = [
{
className: 'row',
fieldGroup: [
{
className: 'col-xs-3',
key: 'supplier',
type: 'select',
templateOptions: {
options: [],
valueProp: 'supplierCode',
labelProp: 'supplierName',
required: false,
onChange: function() {
console.log('vm.InwardLeaseModel.supplier.supplierName');
console.log(vm.InwardLeaseFields.supplier.supplierName);
}
}
}
}];
vm.InwardLeaseFields.supplier仅返回值。
答案 0 :(得分:0)
我自己想出了一个解决方法。
onChange: function(val, key) {
vm.InwardLeaseModel.supplier = vm.getSupplierName(val, key);
}
和功能
vm.getSupplierName = function(value, key) {
var selectedSupplierCode = value;
if(!selectedSupplierCode) {
return '';
} else {
for(var i = 0; i < key.templateOptions.options.length; i++) {
if(key.templateOptions.options[i].supplierCode == selectedSupplierCode) {
return key.templateOptions.options[i].supplierName;
break;
}
}
}
};