【发布时间】:2017-02-16 09:15:48
【问题描述】:
我想使用 Angular 2 材质创建一个动态标签加载器 是我要支持的语法
<generic-tabs [tabs]="tabs" tabVisibleField="name">
<test-cmp [tabContent] testData="hello"></test-cmp>
<test-cmp [tabContent] testData="hello from cmp one"></test-cmp>
<test-cmp [tabContent] testData="hello from cmp 2"></test-cmp></generic-tabs>
在组件内部,我想使用材料设计来渲染选项卡 并将包含 tabContent 的组件绑定到每个选项卡 这是通用标签的模板
<md-tab-group *ngIf="componentsReferences && componentsReferences.length > 0">
<md-tab *ngFor="let componentRef of componentsReferences; let i=index" (click)="onTabClick($event, i)">
<template md-tab-label>{{getDisplayField(i)}}</template>
<template md-tab-content>
//inject the component for this tab
</template>
</md-tab>
</md-tab-group>
我不知道如何选择所有组件 在generic-tabs标签内并制作角度来创建它们
【问题讨论】:
-
这是我到目前为止尝试做的,但如果没有成功。在 rc-06 我得到 create embededView is not a function plnkr.co/edit/TdLZghoOstRqcItmrJg3?p=preview
-
这是我在 rc-0.6 上遇到的错误,与那个 plunk browser_adapter.ts:82 原始异常:TypeError: Cannot read property 'createEmbeddedView' of null
-
browser_adapter.ts:82 TypeError:无法在 ViewContainerRef_.createEmbeddedView (core.umd.js:8344) 处的 ViewContainerRef_.createEmbeddedView (core.umd.js:8344) 处读取属性“createEmbeddedView”为空NgTemplateOutlet.ngOnChanges (common.umd.js:1236) 在 DebugAppView._View_GenericTabsComponent5.detectChangesInternal (GenericTabsComponent.ngfactory.js:369) 在 DebugAppView.AppView.detectChanges (core.umd.js:12586) 在 DebugAppView.detectChanges (core.umd .js:12691)
标签: angular angular2-template angular2-directives