ng-template内容未显示

时间:2019-06-02 11:25:46

标签: angular ng-template ng-container

在我的情况下,如何将Expension-panel包装在模板中? ERROR TypeError: Cannot read property 'details' of undefined  Angular版本4和Angular Material版本2(我知道版本8已经发布,但是我没有机会升级到较新的版本。)

<md-tab-group [selectedIndex]="index" (selectedIndexChange)="index = $event">
	<md-tab label="First">
    <md-list>
        <ng-container *ngTemplateOutlet="tabContent; context: index">
        <md-accordion>
          <div *ngFor="let item of items">
            <ng-container *ngTemplateOutlet="itemList; context: item"></ng-container>
          </div>
        </md-accordion>
    </md-list>
	</md-tab>
	<md-tab label="Second">...</md-tab>
</md-tab-group>
<ng-template #tabContent let-index>Header</ng-template>

<ng-template #itemList let-item>
  <md-expansion-panel>
     <md-expansion-panel-header></md-expansion-panel-header>
     <div class="item-detail">
       <div *ngFor="let detail of item.details">...</div>
     </div>
  </md-expansion-panel>
</ng-template>

0 个答案:

没有答案