Home > Enterprise >  Angular -> Put Username from Cookie into Inputfield
Angular -> Put Username from Cookie into Inputfield

Time:11-17

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

CodePudding user response:

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
 `
  • Related