Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何以角度形式传递字段中的数据?_Angularjs_Angular Formly - Fatal编程技术网

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吗?我相信这相当简单。