Angular - 组件不同的模板 [英] Angular - Component different templates
本文介绍了Angular - 组件不同的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个组件课程".我将此组件用于列表.这个列表有时是水平的,有时是垂直的.我可以在组件内部动态选择模板文件吗?
I have a component "course". I use this component to a list. This list sometimes is horizontal and some times is vertical. Can I choose dynamicaly inside the component the template file?
@Component({
selector: 'course',
templateUrl: getTemplateFile()
})
这样的功能将是很棒的功能!
Something like that would be great feature!
推荐答案
我觉得这个教程很有帮助
I think that this tutorial is very helpful
https://scotch.io/tutorials/component-inheritance-in-角度-2
您可以简单地扩展您的基础组件并覆盖模板.这允许您拥有功能完全相同但模板不同的不同组件.
You can simply extend your base component and overwrite the template. This allows you to have different components with the exact same functionality, but different templates.
这篇关于Angular - 组件不同的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文