How to reset only specific fields of form in angular 5

前端 未结 5 2312
名媛妹妹
名媛妹妹 2021-02-19 20:45

I have created a function in one of my component file that resets the form(myform):

`onSubmit() {
  if (this.myform.valid) {
    console.log(\"Form Submitted!\")         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-19 21:11

    In your html

    
    

    TS

    clearField(value) {
    if (value == 1) {
      this.formularioDeAgendamentoSala.controls['titulo'].reset();
      this.formularioDeAgendamentoSala.controls['dataHoraInicial'].reset();
    }
    

    }

提交回复
热议问题