Par*_*Ark 7 inheritance angular-material2 angular
我正在尝试扩展其中一个Material组件MdTabGroup.使用开箱即用的MdTabGroup组件一切正常 - 材料库正确导入模块等.
这是扩展组件:
@Component({
selector: 'md-custom-tab-group',
templateUrl: 'custom-tab-group.html',
....
})
export class MdCustomTabGroup extends MdTabGroup {
constructor( private _r : Renderer) {
super(_r);
}
}
Run Code Online (Sandbox Code Playgroud)
新组件在app模块中导入并声明,因此创建:
<md-custom-tab-group>
<md-tab>one</md-tab>
<md-tab>two</md-tab>
</md-custom-tab-group>
Run Code Online (Sandbox Code Playgroud)
自定义选项卡组(custom-tab-group.html)的模板与材质中的模板相同,例如
<div class="mat-tab-body-wrapper" #tabBodyWrapper>
<md-tab-body role="tabpanel"
*ngFor="let tab of _tabs; let i = index"
...
[content]="tab.content"
...>
</md-tab-body>
</div>
Run Code Online (Sandbox Code Playgroud)
运行时,_tabsViewChildren集合将正确填充 - 它包含md-tab原始标记中的声明,解释为"材质"选项卡组件.但是,custom-tab-group.html模板是不是有效.模板解析器现在不知道'md-tab-body'是什么.
具体 -
无法绑定到'content',因为它不是'md-tab-body'的已知属性.
但是当我拿起新模板时,我认为它根本不知道md-tab-body是什么.
问题是 - 如何纠正此行为并使扩展组件正常工作?
这不是一个好的答案,但正在跟踪的这个问题似乎是其根源。
https://github.com/angular/material2/issues/9216
一旦它们在导出列表中包含 MatTabBody、MatTabHeader 和 MatTabLabelWrapper,您应该能够扩展它。
| 归档时间: |
|
| 查看次数: |
1532 次 |
| 最近记录: |