2017-12-03 5 views
0

각도 재료 2로 input을 만들려고 노력 중입니다. 가시성 버튼을 누르면 focusinput에 표시되지 않도록하려면 어떻게해야합니까? 여기 그것이 작동하는 방법어떻게 입력에 집중할 수 없습니까?

당신이 볼 수 material.angular.io

를 버튼
After pressing the button

<mat-form-field> 
    <input 
     #mPswd 
     matInput 
     type="password" 
     placeholder="Ваш мастер-пароль" 
     [type]="hide ? 'password' : 'text'" 
    > 
    <mat-icon 
     class="unselectable" 
     matSuffix 
     (click)="hide = !hide" 
    > 
     {{hide ? 'visibility' : 'visibility_off'}} 
    </mat-icon> 
    </mat-form-field> 

답변

0

사용 stopPropagation을 누른 후 버튼
Before pressing the button

을 누르기 전에이 아이콘을 클릭하면

// component.html 
<mat-icon class="unselectable" matSuffix (click)="onIconClick($event)"></mat-icon> 

// component.ts 
onIconClick(event){ 
    event.stopPropagation(); 
    this.hide = !this.hide; 
} 
+0

(클릭) = "onIconClick (** $ ** 이벤트)"가 작동합니다! 고맙습니다! –

+0

@FoprtaTheG. 좋은 포주, 내 말에 오타. – LLai