question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

I 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:

  1. You will get landed on “CRISIS CENTER” page, select any record from it.
  2. Edit some text, and then click on submit button & check the URL in navigation bar.

Note

  1. I’m using template driven form(I don’t think so this will make any difference).
  2. Open Plunkr in Preview window(new tab where you can see running application URL)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
Ferhatoscommented, Oct 11, 2016

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 Script onAction(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.

  • Without form tag, I can’t submit with enter-press-Key.
  • Without naming all the fields of the form, the URL still updated with just a ? before the #

Any workaround is welcome. Thanks.

4reactions
xuwenqing2014commented, Feb 2, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found