如何在Angular中使用基类的html

问题描述 投票:0回答:1

我想在我的角度应用程序中创建一个基本组件,其他组件将从该组件扩展。我想为 html、ts 和 scss 使用一个单独的文件。在这个基础组件中,我想根据数据创建一个表。

我想在从此基础组件扩展的组件中使用该表。我还没有找到如何在其他组件中使用这个 html-table。

我的问题是:如何在其他组件中使用基础组件的html?

我已经搜索了在其他组件中使用基本组件的 html 的方法,并尝试实现这个基类。

angular base-class
1个回答
0
投票

我不会这样做,但如果你愿意,你可以在使用扩展组件时从基本组件获取 css 和 html

    import { Component } from '@angular/core';
import { BaseComponent } from './path-to-base-component';

    @Component({
      templateUrl: './path-to-base.component.html', // Use base component's template
      styleUrls: ['./path-to-base.component.scss']  // Use base component's styles
    })
    export class DerivedComponent extends BaseComponent {
      // Additional logic or overrides here
    }

 
© www.soinside.com 2019 - 2024. All rights reserved.