Create an object inside the class:
class AppComponent { dish = {}; loadDishWindow(){ console.log(this.dish); //->Object {} this.dish = { attributes : [], id : null , name : "", type : null, type_id: null, unit: null, unit_id: null }; console.log(this.dish); //->Object {attributes: Array[0], id: null, name: "", type: null, type_id: nullβ¦} } Why, if I call console.log(this.dish.name); in this method, instead of the last console.log() , for example, then when compiling it gives an error?
error TS2339: Property 'name' does not exist on type '{}'. I use gulp