File

src/module/component/mat-pass-toggle-visibility/mat-pass-toggle-visibility.component.ts

Metadata

encapsulation ViewEncapsulation.None
selector mat-pass-toggle-visibility
styleUrls ./mat-pass-toggle-visibility.component.scss
templateUrl ./mat-pass-toggle-visibility.component.html

Index

Properties
Inputs
Accessors

Inputs

isVisible
Type : boolean

Properties

_type
Type : Type
Default value : 'text'

Accessors

type
gettype()
import {Component, Input, ViewEncapsulation} from '@angular/core';

type Type = 'text' | 'password' ;

@Component({
  selector: 'mat-pass-toggle-visibility',
  templateUrl: './mat-pass-toggle-visibility.component.html',
  styleUrls: ['./mat-pass-toggle-visibility.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class MatPassToggleVisibilityComponent {

  @Input()
  isVisible: boolean;

  _type: Type = 'text';

  get type() {
    return this.isVisible ? 'text' : 'password';
  }

}
<button (click)="isVisible = !isVisible"
        type="button"
        class="mat-icon-button cdk-focused cdk-mouse-focused" mat-icon-button
        matRippleCentered="true"
        matRipple>
  <mat-icon>{{isVisible ? 'visibility' : 'visibility_off' }}</mat-icon>
</button>

./mat-pass-toggle-visibility.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""