Component Boiler Plate
Breakdown and explanation of Angular's Component Boilerplate
What is Boiler Plate?
BOILER PLATE: In computer programming, boilerplate code or just boilerplate are sections of code that have to be included in many places with little or no alteration. When using languages that are considered verbose, the programmer must write a lot of code to accomplish only minor functionality For example EVERY HTML file will have something like the below code no matter the website. Our components will have Boilerplate Code as well.
Component Boilerplate Breakdown
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