在Angular 8之前,我们使用import { NgModule } from '@angular/core';语句来导入NgModule模块。但是在Angular 8中,NgModule模块的导入语法有所改变。
在Angular 8中,我们使用import { NgModule } from '@angular/core';语句导入NgModule模块时,还需要添加@angular/common模块的导入语句。具体代码示例如下:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [
    // 组件声明
  ],
  providers: [
    // 服务提供者
  ]
})
export class MyModule { }
在上面的代码中,我们通过import { CommonModule } from '@angular/common';语句导入了CommonModule模块。然后在NgModule的imports数组中添加了CommonModule模块。
这是因为在Angular 8中,CommonModule被分成了独立的模块,而不再是@angular/core的一部分。因此,我们需要单独导入CommonModule模块来使用其中的指令和管道。
需要注意的是,CommonModule是一个常用的模块,它提供了一些常用的指令和管道,如*ngIf、*ngFor等。如果你的模块中使用到了这些指令和管道,就需要导入CommonModule模块。
除了CommonModule模块之外,还有其他模块也需要单独导入,具体取决于你的代码中使用了哪些模块。在导入模块时,可以根据需要自行添加所需的模块。
希望对你有所帮助!