Component Boiler Plate
Breakdown and explanation of Angular's Component Boilerplate
What is Boiler Plate?
Component Boilerplate Breakdown
import { Component } from "@angular/core";
@Component({})
export class MyComponent {}
Importing the component class from @angular/core so we can create an instance of the component class. Other imports from Angular Core will sometimes be included here as well.z
Line 3: This lets you create an Angular Component using some defaults and the @ Component decorator
Line 5: Lastly the component is exported so we can import it into the app.module.ts
Recap
All components have boilerplate that we do not have to write or memorize. The key points to focus on are that each component has a selector that we can use in our HTML and each component must have this boilerplate code work as long as being imported into the app.module.ts. More on that in the next page.
Last updated