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

Material UI Element does not shown until I click

The inputs for username and password are not displayed until I click somewhere. Either on the login button or wherever on the above buttons.

before I click:

So looks before I click

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

after I click:

So looks after I click

Angular : 13

log-in.component.html

    <div class="login-wrapper" fxLayout="row" fxLayoutAlign="center center">
        
      <mat-card class="box">
          
        <mat-card-header>
          <mat-card-title>Log in</mat-card-title>
        </mat-card-header>
          
    
        <form [formGroup]="form" (ngSubmit)="onSubmit()">
            
          <!--    Benutzername Field    -->
          <mat-form-field appearance="outline">
            <mat-label>Benutzername</mat-label>
            <input
              matInput
              type="text"
              formControlName="username">
            <!--  hier wird das icon von benutzernane platziert  -->
            <mat-icon matSuffix>person</mat-icon>
          </mat-form-field>
          <!--   ENDE - Benutzername Field    -->
            
            
          <!--    Kennwort Field    -->
          <mat-form-field appearance="outline">
            <mat-label>Kennwort</mat-label>
            <input
              matInput
              type="password"
              formControlName="password">
              <!--  hier wird das icon von Kennwort platziert  -->
            <mat-icon matSuffix>password</mat-icon>
          </mat-form-field>
          <!--    ENDE - Kennwort Field    -->
    
                <button
                    mat-stroked-button color="primary"
                    type="submit"
                    class="btn-block">Anmelden</button>
    
            </form>
        </mat-card>
    </div>

log-in.component.ts

    @Component({
      selector: 'app-log-in',
      templateUrl: './log-in.component.html',
      styleUrls: ['./log-in.component.css']
    })
    export class LogInComponent implements OnInit {
        form: FormGroup = new FormGroup({
            name: new FormControl(''),
            password: new FormControl(''),
          });
          serverErrorPasswordMessage:string = '';
          submitted = false;
    
      constructor(private formBuilder: FormBuilder, private http: HttpClient, private router: Router) { }
    
      ngOnInit(): void {
      }
      onSubmit(): void {               
      }

UPDATE:
that is what i see in the console:

enter image description here

>Solution :

your error message states that the control "username" cannot be found on your FormGroup.

Either change your view control name to "name"

        <input
              matInput
              type="text"           \/ *** here    
              formControlName="username">

or your form control definition to "username"

form: FormGroup = new FormGroup({
             \/ *** here
            name: new FormControl(''),
            password: new FormControl(''),
          });
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