Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular -> Put Username from Cookie into Inputfield

I have a Webapplication with oAuth, the Webapplication contains a Inputifeld for the Users loginName.
The Loginname also is in the Cookie from the oAuth.
I now want to get that username from the Cookie and put it into the inputfield so that the User doesen’t has to type it in by themselves. But the user should also have the Option to change the Input if he wants to.

This is my Inputfield:

<div class="input-field-userName">
    <div class="input-field input-oneline center-block" data-init="auto" style="width: 20%;">
      <input
        [formControlName]="homeForm.Username"
        [name]="homeForm.Username"
        type="text"
        id="userName"
        placeholder="userName"
        ngModel pattern="^t\w{4,9}$">
    </div>
  </div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you can set the default value during initialization of the form . The default username can be read from cookie

`registerForm = new FormGroup({
 userName: new FormControl('alvic'),  // add default value
 `
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading