2017-11-09 5 views
0

私はdynamically setting/creating the placeholder textという入力があります。Angularを使用して、ページの読み込み時にフォーム要素/値の不透明度を設定するにはどうすればよいですか?

すべてがうまくいきます。例外として、ページの初期値がロードされているときにデフォルトで入力値が0の不透明度に設定されている場合は例外です。もしそうなら、入力に1の不透明度を与えますか?

template.htmlは

<input type="search" matInput placeholder="My Placeholder" 
    aria-label="My Placeholder" 
    [matAutocomplete]="mySearch" 
    [formControl]="myCtrl 
    (focus)="onInputFocus()" 
    [(ngModel)]="myModel"> 

答えて

0

あなたは右の入力にNgStyleを使用して試すことができます。例えば

template.html

<input type="search" matInput placeholder="My Placeholder" 
    aria-label="My Placeholder" 
    [matAutocomplete]="mySearch" 
    [formControl]="myCtrl 
    (focus)="onInputFocus()" 
    [ngStyle]="{'opacity':myAttribute.myVaue !== '' ? '1' : '' }" // Set the default opacity 
    [(ngModel)]="myModel"> 
関連する問題