Posts

Showing posts with the label Angular Forms

Angular 2: Form Submission Canceled Because The Form Is Not Connected

Answer : There might be other reasons this occurs but in my case I had a button that was interpreted by the browser as a submit button and hence the form was submitted when the button was clicked causing the error. Adding type="button" fixed the issue. Full element: <button type="button" (click)="submitForm()"> In the form tag you should write the following: <form #myForm="ngForm" (ngSubmit)="onSubmit()"> and inside the form you should have submit button: <button type="submit"></button> And most importantly, if you have any other buttons in your form you should add type="button" to them. Leaving the default type attribute (which I think is submit ) will cause the warning message. <button type="button"></button> So I actually just ran into the exact same problem today except without a modal involved. In my form, I have two buttons. One that submit...