Creating an Angular component

Next, we will create a todo component. We can easily do that with the Angular-CLI, with this command:

ng generate component todos

This generates the following files: todos.component.ts, todos.component.html, and todos.component.ts. The todos component is also automatically imported into app.module.ts:

// app.module.tsimport { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@angular/core';import { AppComponent } from './app.component';import { TodosComponent } from './todos/todos.component';@NgModule({declarations: [AppComponent,TodosComponent],imports: [BrowserModule],providers: [],bootstrap: [AppComponent]})export class AppModule { }

We should be sure to add a <base href="/"> within ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.