Submodule 20.2: Data Binding - Practice
Updating the .ts files
Open menu.component.ts
file and update its content. First, delete the dishes constant and then make the following changes:
Note that we have separated the Choco-dish data from our code and we now import these from the DISHES/dishes.ts
Open dishdetail.component.ts
and update its contents as follows:
Note the use of the Input module.
This module allows us to declare a decorator - @Input()
- inside which we define the dish variable
.
We also need to import { Dish } from '../shared/dish';
This is a way to transfer information from one component (dishdetail) from another component (menu).