angular + monitor changes on form Form

// If you use the form

 loopholeForm: FormGroup;

 constructor(
    fb: FormBuilder,
    private modalRef: NzModalRef,
    private message: NzMessageService,
    private cveService: CveService
  ) {
    this.loopholeForm = fb.group({
      loophole: [null], 
      cveName: [ null ]
      cnnvdName: [ zero ],
      grade: [null]
    });
  }

ngOnInit () {
// monitor changes in the whole form 
    the this .loopholeForm.valueChanges.subscribe (Data => the console.log ( 'form' , Data));
 // single control changes 
    the this . .LoopholeForm.get ( 'cveName') valueChanges.subscribe ( = Data> the console.log ( 'Solo' , Data));
  }
 < NZ-form-Item > 
              < NZ-form-label nzRequired > CNNVD ID </ NZ-form-label > 
              < NZ-form-Control nzErrorTip = "cnnvd number can not be empty" > 
                < INPUT
                   type = "text"
                  nz-input
                  nzSize="default"
                  formControlName="cnnvdName" // 这里绑定
                  autocomplete="off"
                  placeholder="CNNVD编号"
                  maxlength="255"
                />
              </nz-form-control>
            </nz-form-item>

Guess you like

Origin www.cnblogs.com/gushiyoyo/p/12091549.html