2016-11-23 6 views
0

私は次のコードを持っている:Angular2材料アクセス]タブの外側それ

<md-tab-group> 
      <md-tab *ngFor="let section of sectionList"> 
     <template md-tab-label> 
<span (click)="selectedSection=section"> 
      {{section.name}} 
</span> 
     </template> 
     </md-tab> 
     </md-tab-group> 

私はタブループ外現在の選択したセクション(sectionオブジェクト)のデータを表示することができますどのように?

span(click)を追加しようとしましたが、トリガーできませんでした。

+0

[Plunker](https://plnkr.co/)を入力してください。 –

答えて

0

タブグループにはselectedIndexプロパティがありますので、template referenceを作成して使用することができます。

<md-tab-group #tabGroup> 
<md-tab *ngFor="let section of sectionList"> 
    <template md-tab-label> 
    <span (click)="selectedSection=section"> 
     {{section.name}} 
    </span> 
    </template> 
</md-tab> 
</md-tab-group> 
<div>{{sectionList[tabGroup.selectedIndex].name}}</div>