Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
Angular2 form submit stops working after route change

Given my form:

 <form #f="ngForm" (ngSubmit)="saveNew(f)">
        <div class="form-group">
            <label><strong>Text Hu</strong></label>
            <quill-editor name="textHU" [ngModel]="textHU">
            </quill-editor>

            <label class="mt-4"><strong>Text En</strong></label>
            <quill-editor name="textEN" [ngModel]="textEN">
            </quill-editor>
        </div>
        <button type="submit" class="btn btn-primary">Save</button>
    </form>

Component:

  saveNew(form: NgForm) {
        this.termsOfServiceNew.text.textEN = form.value.textEN;
        this.termsOfServiceNew.text.textHU = form.value.textHU;
        this.http.post("/api/terms_of_service/admin", this.termsOfServiceNew, this.jsonRequestOptions).subscribe(r => {
            this.termsOfServiceNew.text.textEN = "";
            this.termsOfServiceNew.text.textHU = "";
            this.toggleNewContainer();
            this.refreshList();
        });
    }

Every form have this attribute: #f="ngForm"

Should this #f be unique for every form?

Angular base app was generated by JHipster (springboot back-end).

I have several similar forms in my app, in different components on different routes. When I load or reload my app (ctrl+f5) and submits the form it works perfectly. It calls my API, saves data into DB. I can repeat it, it works fine, but when i navigate elsewhere (different route) then all my forms across the application stops working. When I hit the submit button, does not happen anything. No error on console, ngSubmit methods are not called anymore.

Do you have any idea, what could cause this strange issue?

Thanks for any help!

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda