Angular 2: Form submission canceled because the form is not connected

前端 未结 10 724
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 13:03

I have a modal that contains a form, when the modal is destroyed I get the following error in the console:

Form submission canceled because the form i

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 13:31

    In the form element you need to define submit method (ngSubmit), something like:

    and on the submit button you omit click method, because your form is now connected to the submit method: The button should be of submit type.

    In the code behind component you implement "onSubmit" method, for example something like this: onSubmit(value: ICurrency) { ... } This method is receiving an value object with values from the form fields.

提交回复
热议问题