角形式禁用多复选框中的复选框

时间:2018-09-10 15:31:12

标签: angular-formly

我正在使用angular-formly构建表单,并且如果要单击特定复选框,我想禁用多复选框中的所有复选框。

例如,例如:

如果用户单击“我不想回答”,请禁用多复选框中的所有其他复选框

https://jsbin.com/sunozin/edit?html,js,console,output

{
    key:"aboriginal",
    type:"multiCheckbox",
    templateOptions:{
      label:"",
       labelProp:"aboriginal",
      valueProp:"id",

      options:[
        {
          aboriginal:"First Nations, Status Indian, Non-Status Indian",
          value:"   First Nations, Status Indian, Non-Status Indian",
          id:1
        },
        {
          aboriginal:"No, not an Indigenous person",
          value:"No, not an Indigenous person",
          id:2
        },
        {

          aboriginal:"Inuk (Inuit)",
          value:"Inuk (Inuit)",
          id:3
        },
        {
          aboriginal:"I do not wish to answer",
          value:"I do not wish to answer",
          id:999
        }
      ],
      onClick: function hideaboriginal($modelValue, fieldOptions, scope, event) {
        console.log(scope.model.aboriginal);
          if(scope.model.aboriginal.indexOf(999) !== -1) 
          {
            console.log("i do not wish to anser");
            //disable all other checkboxes
          }
      }
    }
  }

0 个答案:

没有答案