Angular中的ng-template

Angular中的ng-template

ng-template 是用來定義模板的,當使用ng-template定義好一個模板之後,可以用ng-container和templateOutlet指令來進行使用。
<ng-template #loading>
  <button (click)="login()">login</button>
  <button (click)="sigup()">sigup</button>
</ng-template>
<ng-container *ngTemplateOutlet="loading">

</ng-container>

ng-template在編寫高定製性的組件時非常有用。可以把需要定製的內容作爲模板傳到組件中。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章