Passing Props to Child Component in Angular
You can also pass properties from a parent component to a child component. Let's see how this is done. In the parent component, we'll set the properties that we'll pass to the child component:
class AppComponent {
public name: string = 'john';
public age: number = 25;
}
In the parent template, we take the attribute names into square properties. In this case, what is written as the attribute value will be interpreted as a property of the parent class:
<user-data [name]="name" [age]="age"></user-data>
In the parent component, create properties for the product name and price. Pass their values to your child component.