2017-04-26 11 views
0

ourcomponent HTMLには参照名を持つモーダルがあります。このモーダルの中には、モーダルを閉じるためのボタンがあります。ここで参考にしてAngularテンプレートでこれを使用する

コードは次のとおりです。

<div bsModal #confirmModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirm modal" aria-hidden="true"> 
    <div class="modal-dialog modal-md"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
     <h4 class="modal-title pull-left">Confirm</h4> 
     <button type="button" class="close pull-right" aria-label="Close" (click)="confirmModal.hide()"> 
     <span aria-hidden="true">&times;</span> 
     </button> 
     </div> 
     <div class="modal-body"> 
     <span>Are you sure ?</span> 
     </div> 
     <div class="modal-footer"> 
     <button type="button" class="btn btn-default" (click)="confirmModal.hide()">Cancel</button> 
     <button type="button" class="btn btn-danger" (click)="confirmModal.hide()">Refresh Data</button> 
     </div> 
    </div> 
    </div> 
</div> 

それを閉じるには、我々は現在、たとえば(click)="confirmModal.hide()"を求めます。参照名を使用する。我々は参照#confirmModal内側のdivあるので

それは多分私はこの構文を試してみました。もちろん、(click)="this.hide()"

使用して非表示の機能を呼び出す方法を持つことが可能であり、それはように動作しません。私が理解しているように、thisはコンポーネントを指しています。

ボーナスとして、このリファレンス構文#referenceについてAngular docの情報がどこにあるのかわかりますか?私はすべての可能性を正確に知らなくてもそれを使用します。

+0

私の知る限り、「this」はHTMLの範囲にはありません。 – DeborahK

答えて

関連する問題