# Random Password and Toggle

{% code fullWidth="true" %}

```
// Some code Toggle Password Visibility (hide/show password)


  import { MatIconModule } from '@angular/material/icon';

 
  <input class="form-control"  formControlName="newPassword"  [type]="showPassword ? 'text' : 'password'" />

  <mat-icon matSuffix (click)="togglePasswordVisibility()"
      style="color: rgb(107, 66, 4); padding:3px 30px 2px 16px; cursor:pointer;">
             {{showPassword?'visibility':'visibility_off'}}
  </mat-icon>



  public showPassword: boolean = false;

   togglePasswordVisibility(): void {
    this.showPassword = !this.showPassword;
  }


```

{% endcode %}

{% code fullWidth="true" %}

```
// Random password

  <input autoComplete="new-password" cFormControl formControlName="Password" placeholder="Password"
    title="Password must be at least 6 characters" [type]="showPassword ? 'text' : 'password'" />
  <a class="pointer text-success" style="padding:6px 2px 0 20px ; cursor:pointer; font-size: x-large;"
    (click)="randomKey();"> <i class="fa fa-key " title="Password generator"></i></a>

randomKey() {
  this.randomPassword = Math.random().toString(36).slice(-8);
  this.frm.controls['Password'].setValue(this.randomPassword);
}


```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ai-candy2023.gitbook.io/introduction/programming/angular/display-pipe-ui-format/random-password-and-toggle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
