Creating a Component
How to create a component with Angular CLI
ng generate component my
// both commands will do the same thing
$ ng g myImporting a Component to app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { MyComponent } from './my.component';
@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent, MyComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Import { Component } from "@angular/core"; (
@Component({
selector: "my-component",
templateURL: './my.component.html'.
styles: [['h1 { font-weight: normal; }']]
})
export class MyComponent {
constructor(){}
}App.module.ts Explanation
Last updated