angular 12 model class 1

angular 12 model class

//Define how single recipe should look like - Blueprint for object
export class Recipe {

    public name : string;
    public description : string;
    public imagePath : string;

    constructor(name : string, desc : string, imagePath : string){ = name;
        this.description = desc;
        this.imagePath = imagePath;


Here is what the above code is Doing:
1. We are creating a class called Recipe.
2. We are defining the blueprint for the object.
3. We are defining the constructor for the class.
4. We are defining the properties of the class.
5. We are exporting the class so that it can be used in other files.

Now, let’s create a new file called recipe-list.component.ts and add the following code to it:

Similar Posts