Angular 2 new form(0.2.0), on submit redirecting to same page with form fields are appended to URL as query params with new Router(3.0.0-beta.1)
See original GitHub issueI was updating my old running application to newer angular version. It was working good with older version.
On one of my page, I have used form, so when I updated angular/forms
to 0.2.0
version with component router version 3.0.0-beta.1
. The issue I’m facing is when I tried to submit form, it redirects to same page and appending all the entered value in query parameter.
Here is Plunkr with Problem statement
Steps to reproduce issue:
- You will get landed on “CRISIS CENTER” page, select any record from it.
- Edit some text, and then click on submit button & check the URL in navigation bar.
Note
- I’m using template driven form(I don’t think so this will make any difference).
- Open Plunkr in Preview window(new tab where you can see running application URL)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Angular 2 new form, on submit redirecting to same page with ...
On one of my page, I have used form, so when I updated angular/forms to 0.2.0 version with component router version 3.0.0-beta.1 ....
Read more >Reactive forms - Angular
Reactive forms provide a model-driven approach to handling form inputs whose values change over time. This guide shows you how to create and...
Read more >A Simple, Reusable Solution for Binding URL Query Params ...
A common behavior in web applications is to sync data in forms based on the values of the URL query params. For example,...
Read more >Changelog | Meteor API Docs
Adjusted config to Auto import React on jsx,tsx files PR. needs to use directly from npm the meteorjs/babel@7.16.1-beta.0. Breaking Changes. N/A ...
Read more >Angular 5 Tutorial: Guide to Your First Angular 5 App - Toptal
There are two major versions of the framework: AngularJS (version 1) and Angular ... You can look at the ng new output form...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
EDIT : I found a workaround/solution
I found a workaround/solution. Just return false on submit function 😉
HTML
<form class="card-block" role="form" #form="ngForm" novalidate (ngSubmit)="onAction(save)">
Type ScriptonAction(action) { this.action.emit(action); return false; }
stackoverflow stackoverflow - origin
History
Hi, I have the same problem. I just wanna submit a form in a Modal. I’m using ng2-bs3-modal@0.10.4. In other forms where I refresh or navigate to another route, I have no probleme. But in case using modal, I didn’t want to refresh/navigate to URL. But the URL is updated with form fields.
Any workaround is welcome. Thanks.
sorry, I met the same problem too. The button can work normally in my local environment, but when I use ‘ng build --prod --output-hashing=none’ to build my code, the button will redirect to a url to refresh current page. it can be reproduce in the website ‘http://jpush-ui.jpushoa.com/#/login’. please.