Angularjs 如何以角度形式传递字段中的数据?
所以我有这些字段Angularjs 如何以角度形式传递字段中的数据?,angularjs,angular-formly,Angularjs,Angular Formly,所以我有这些字段 vm.prepFields = [ { key: 'shirt', type: 'select', templateOptions: { label: 'Choose Shirt Size', placeholder: 'Select option', options: shirt_list } }, { key: 'shortsq', t
vm.prepFields = [
{
key: 'shirt',
type: 'select',
templateOptions: {
label: 'Choose Shirt Size',
placeholder: 'Select option',
options: shirt_list
}
},
{
key: 'shortsq',
type: 'checkbox',
templateOptions: {
label: 'Shorts',
}
},
{
key: 'shorts',
type: 'select',
templateOptions: {
label: 'Choose Shorts Size',
options: shorts_list
}, expressionProperties: {
hide: '!model.shortsq'
}
}
];
}
shortsq是一个复选框,单击该复选框时显示shorts select选项…如果选中shorts,我如何传递值
e、 假设一件衬衫的价格是10美元,我希望在检查短裤时,价格能提高5美元。如何实现这一点?使用templateOptions中的onChange可以轻松实现这一点:
{
key: 'shortsq',
type: 'checkbox',
templateOptions: {
label: 'Shorts',
onChange: function($viewValue, $modelValue, $scope) {
if($scope.model.shortsq) $scope.model.shirtPrice += 5; //increase price by $5 when checked
else $scope.model.shirtPrice -= 5; //reduce price by $5 when not checked
}
}
},
你能安装一个plunkr吗?我相信这相当简单。