2
<div class="content">
  <md-tab-group>
    <md-tab label="label1" (click)="passSourceOfDocuments()">
      <details *ngFor="let package of documentPackages">
        <summary>{{package.documentPackageGuid}}</summary>
        <ul>
          <details *ngFor="let doc of package.Documents">
            <summary>{{doc.documentGuid}}</summary>
              ..........
          </details>
        </ul>
      </details>
    </md-tab>
    <md-tab label="label2" (click)="passSourceOfDocuments()">
      <details *ngFor="let doc of emaildocuments">
             ......................
      </details>
    </md-tab>
  </md-tab-group>
</div>

I would pass name of label in function "passSourceOfDocuments()" it is possible ? Can I bind this label with property in .ts file ?

Walter White
  • 976
  • 4
  • 12
  • 29

1 Answers1

4

If you can add a 'template reference variable' to each of your <md-tab> elements, then you could refer to them in the function like this,

<md-tab #tab1 label="label1" (click)="passSourceOfDocuments(tab1.textLabel)">
<md-tab #tab2 label="label2" (click)="passSourceOfDocuments(tab2.textLabel)">

Or if you have an array of labels declared as a property in the component file, then you can add them by index or some similar means,

component

labelsArr = ['label1', 'label2', 'label3'];

template

<md-tab [label]="labelsArr[0]" (click)="passSourceOfDocuments(labelsArr[0])">
<md-tab [label]="labelsArr[1]" (click)="passSourceOfDocuments(labelsArr[1])">
amal
  • 3,140
  • 1
  • 13
  • 20