The component is one of the building blocks of the ionic framework. Here we will be creating our own custom component. Components are the class, with HTML template. For our custom component have a decorator that is @Component, to add metadata to a class to describe the component.
- We can create a custom component, that can be used anywhere. Data in the component are private.
- Component name <app-person>, in our case. using in home.html page
- Learning *ngIf and else condition
Our Apps we have a custom component with its own variables and template.
Step 1: ionic start myComponent blank
Step 2: Create a person component
Step 3: Add the following code in person.component.html
Step 4: Add the following code in person.component.html
Step 4: Import custom component in a page where we want to use, in our case home.module.ts. Add PersonComponen in @NgModule declarations, entry component.
Step 5: Now we can use our custom component in our page, add custom component tag in home.html