ng-editormd.module.ts 的实现代码如下:
import { EditormdComponent } from './ng-editormd.component';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
@NgModule({
declarations: [EditormdComponent],
imports: [CommonModule],
exports: [EditormdComponent],
})
export class EditormdModule {}
在 angular 16 与 angular 17 中都正常,升级到 angular 19 后 build 时报错:
projects/ng-editormd/src/lib/ng-editormd.module.ts:6:20 - error NG6008: Component EditormdComponent is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?
6 declarations: [EditormdComponent],
~~~~~~~~~~~~~~~~~
projects/ng-editormd/src/lib/ng-editormd.module.ts:8:15 - error NG6004: Can't be exported from this NgModule, as it must be imported first
8 exports: [EditormdComponent],
~~~~~~~~~~~~~~~~~
请问如何解决这个问题?
angular 18 与 angular 19 已经不需要 NgModule
,删除 ng-editormd.module.ts
文件,并且从 public-api.ts
中删除下面的代码,即可解决
export * from './lib/ng-editormd.module';