Clearing an input text field in Angular2

前端 未结 7 1481
臣服心动
臣服心动 2020-12-28 12:56

Why is this method not working when I try to clear the text field?

相关标签:
7条回答
  • 2020-12-28 13:28

    This is a solution for reactive forms. Then there is no need to use @ViewChild decorator:

      clear() {
        this.myForm.get('someControlName').reset()
      }
    
    0 讨论(0)
提交回复
热议问题