0

I created a new component,But I can not read it in the app.

In my main component file: app.component.html I have:

<h1>First App</h1>
<app-red-light></app-red-light>

In my second component file: red-light.component.html

I have:

<p>red-light works!</p>

Which I call red-light In main components so it does not appear to me

My 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 { }
5
  • Did you add RedLightComponent to your AppModule? Do you get any errors in your console? Commented May 15, 2022 at 14:22
  • It should automatically be added there as soon as I create components Commented May 15, 2022 at 14:28
  • And I do see it there Commented May 15, 2022 at 14:29
  • I added all my code in the app.module Commented May 15, 2022 at 14:30
  • @JorgeDask in that case please share the code (or minimal code that demonstrates the issue) on Stackblitz Commented May 15, 2022 at 17:42

1 Answer 1

1

Have you re-builded your application once more? Changes involving the modules(for instance creating new components) require running the application by ng serve again

Sign up to request clarification or add additional context in comments.

1 Comment

My Bad, I did not connect to localhost: 4200

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.