Formation Angular Lab 2 More Components: Lab 2.1: Data Flowing Downwards
Formation Angular Lab 2 More Components: Lab 2.1: Data Flowing Downwards
2. Start ng serve:
3. Open app:
@Component({
selector: 'app-root',
template: `
<car *ngFor="let car of cars" [theCar]="car"></car>
`,
styles: []
})
make: string,
model: string
}
styles: [] })
The Application component has a list of three cars. We use the ngFor
directive to iterate over the list of cars, generating a Car component for each
one. We use the theCar input property to pass the car to the Car component.
We have a Car component to display each car. In the Car component, we use
the theCar aliased input property to accept the car instance variable from the
outside.
cd more-components-ex200
ng serve
3. Open app:
deleteCar(car: ICar){
alert('Deleting car:' + JSON.stringify(car));
}}
5. Create ICar interface:
styles: [] })