【发布时间】:2017-04-05 16:42:52
【问题描述】:
我来自Laravel 世界,对Angular 2 世界有点陌生,我很难弄清楚:
是否可以在 Angular 2 中覆盖组件或模板,就像我们在 Laravel 中覆盖供应商/自定义包的视图一样?
这是一个虚拟文件夹结构,可以表达我的意思:
|-resources
|-assets
|-typescript
|-core
|-core.component.ts //overridded core component and template
|-core.template.html
|-Modules
|-Core
|-Resources
|-assets
|-typescript
|-core
|-core.component.ts //main module component and template
|-core.template.html
core.template.html(原文)
<div>
<p> This is a core component's template</p>
<button>Click me! </button>
</div>
core.template.html(覆盖)
<div>
<p> This is a overridden core component's template</p>
<p> Removed the button and overridden with p-tag </p>
</div>
希望我已经清楚地说明了我面临的问题。
【问题讨论】:
-
视情况而定,但至少对于其中一些,这可以通过条件导入包含并发组件的 NgModule 来解决。
标签: laravel angular overriding modular angular-template