Will Diaz Asked: 2022-04-09 07:02:33 +0800 CST 2022-04-09 07:02:33 +0800 CST 2022-04-09 07:02:33 +0800 CST ANGULAR property access problem 772 I have the following code in Angular, with an array of objects, I try to iterate through it with the directive ngForbut for some reason I can't access the properties of the object, it tells me that the property of the object doesn't exist angular 1 Answers Voted Best Answer Legna 2022-04-09T08:07:01+08:002022-04-09T08:07:01+08:00 The quick fix is to add ?. {{entrada?.frase}} The optimal solution would be to tell the compiler the type of data you are receiving with an interface: //Esto lo puedes poner fuera de la clase del componente. interface Frase { frase:string } this.entradas:Frase[] = [{frase: "Tu frase"}]
The quick fix is to add
?
.The optimal solution would be to tell the compiler the type of data you are receiving with an interface: