2017-05-19 7 views

答えて

4
にご pasteイベントを変更

(paste)="onPaste($event)" 

そして、あなたは可能性があなたのコンポーネントで:

onPaste(e: any) { 
    let content = myRegex.match(e); // should return boolean 

    if (!content) { 
    this.myModel = ''; // We clear it if it doesn't match 
    } 
} 

あなたの入力は次のようになります。

<input type="text" [(ngModel)]="myModel" (paste)="onPaste($event)"> 
関連する問題