By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
rocoderesrocoderes
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Notification Show More
Latest News
How to set the dropdown value by clicking on a table row
Javascript – How to set the dropdown value by clicking on a table row
JavaScript
Attempting to increase the counter, when the object's tag exist
Javascript – Attempting to increase the counter, when the object’s tag exist
JavaScript
Cycle2 JS center active slide
Javascript – Cycle2 JS center active slide
JavaScript
Can import all THREE.js post processing modules as ES6 modules except OutputPass
Javascript – Can import all THREE.js post processing modules as ES6 modules except OutputPass
JavaScript
How to return closest match for an array in Google Sheets Appscript
Javascript – How to return closest match for an array in Google Sheets Appscript
JavaScript
Aa
Aa
rocoderesrocoderes
Search
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Follow US
High Quality Design Resources for Free.
rocoderes > JavaScript > Javascript – how to get prefix values in angular input field
JavaScript

Javascript – how to get prefix values in angular input field

Admin
Last updated: 2024/02/10 at 7:08 AM
Admin
Share
1 Min Read
how to get prefix values in angular input field

Problem:

I tried to add prefix on input field its perfectly ok but after submit form that value is not attached with input field value.

Contents
Problem:Solution:
<form
    nz-form
    [formGroup]="invoiceForm"
    (ngSubmit)="saveInvoiceData(invoiceForm.value);" >
    <div class="row">
      <div class="col-lg-4 form-group">
        <div class="label-mini">
          <span>Reference</span>
        </div>
        <nz-input-group nzPrefix="REF-">
          <input
            type="text"
            nz-input
            nzSize="large"
            placeholder="Reference Name"
            formControlName="reference" />
        </nz-input-group>
      </div>
    </div>

    <button
      class="primary-btn"
      type="submit"
      [disabled]="invoiceForm.invalid">
      Submit
    </button>

</form>

on ts component:

initializeForm() {
    this.invoiceForm = new FormGroup({
      reference: new FormControl(''),
    })
  }

I already attached prefix value REF- and when i submit form its not submit as like REF-12345

Its only get 12345

Solution:

To include the prefix value in the form data, you will need to manually add it to the value of the reference form control.

saveInvoiceData(formData) {
  const referenceValue = formData.reference;
  const prefixedReferenceValue = `REF-${referenceValue}`;
  // Submit the prefixed reference value
  console.log(prefixedReferenceValue);
}

Related

Subscribe to Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Share this Article
Facebook Twitter Email Print
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article How to get elements from an array that do not have certain letter, just using the for loop? Javascript – How to get elements from an array that do not have certain letter, just using the for loop?
Next Article How to convert this class component to functional component Javascript – How to convert this class component to functional component
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

- Advertisement -

You Might Also Like

How to set the dropdown value by clicking on a table row

Javascript – How to set the dropdown value by clicking on a table row

February 11, 2024
Attempting to increase the counter, when the object's tag exist

Javascript – Attempting to increase the counter, when the object’s tag exist

February 11, 2024
Cycle2 JS center active slide

Javascript – Cycle2 JS center active slide

February 10, 2024
Can import all THREE.js post processing modules as ES6 modules except OutputPass

Javascript – Can import all THREE.js post processing modules as ES6 modules except OutputPass

February 10, 2024
rocoderesrocoderes
Follow US

Copyright © 2022 All Right Reserved By Rocoderes

  • Home
  • About us
  • Contact us
  • Disclaimer
Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc.

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?