Angular: 无法调用我创建的组件
Angular: Can't call component I created
我创建了一个新组件,但我无法在应用程序中读取它。
在我的主要组件文件中:app.component.html
我有:
<h1>First App</h1>
<app-red-light></app-red-light>
在我的第二个组件文件中:red-light.component.html
我有:
<p>red-light works!</p>
我叫红灯
在主要组件中,所以它在我看来没有
我的App.Module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { RedLightComponent } from './red-light/red-light.component';
@NgModule({
declarations: [
AppComponent,
RedLightComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
您re-builded再次申请了吗?涉及模块的更改(例如创建新组件)需要 运行 再次 ng serve
申请
我创建了一个新组件,但我无法在应用程序中读取它。
在我的主要组件文件中:app.component.html 我有:
<h1>First App</h1>
<app-red-light></app-red-light>
在我的第二个组件文件中:red-light.component.html
我有:
<p>red-light works!</p>
我叫红灯 在主要组件中,所以它在我看来没有
我的App.Module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { RedLightComponent } from './red-light/red-light.component';
@NgModule({
declarations: [
AppComponent,
RedLightComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
您re-builded再次申请了吗?涉及模块的更改(例如创建新组件)需要 运行 再次 ng serve
申请