ng g component components/news
创建一个news组件
<app-news></app-news> 可以在其他组件中通过这个名称引入
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NewsComponent } from './components/news/news.component';
<!--引入组件-->
import { HeaderComponent } from './components/header/header.component';
@NgModule({
declarations: [
AppComponent,
NewsComponent,
HeaderComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
来源:CSDN
作者:小汪4code
链接:https://blog.csdn.net/qq_32527287/article/details/104755736