title: Angular - Access to object attribute with a string variable in property binding
body: <p>I would like to use a string &quot;attribute&quot; as a key to access the value of a field in the &quot;anim.animals&quot; object.</p>
  <p>&quot;anim&quot; is an object of type Response that contains among other things the string &quot;attribute&quot; and an array &quot;animals&quot; of type animal.</p>
  <p>(you can beat me up later for naming classes and variables ahah)</p>
  <p>As you can see from the piece of code I'm iterating through the array to access the animals parameters, one of which is identified by the string &quot;attribute&quot;.</p>
  <pre><code>&lt;div class=&quot;col-sm&quot; *ngFor=&quot;let a of anim.animals&quot;&gt;
             &lt;a&gt;{{a.name}}&lt;/a&gt;&lt;br&gt;
             &lt;a *ngIf=&quot;feedback == 'Wrong'&quot;&gt;{{a[attribute as keyof typeof animal]}}&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Both trying to access it with the dot and in this reported way (which I found on the internet and don't know well yet), errors appear:</p>
  <ul>
  <li>error NG5002: Parser Error: Missing expected ] at column 13 in [{{a[attribute as keyof animal]}]</li>
  <li>error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'animal'. No index signature with a parameter of type 'string' was found on type 'animal</li>
  </ul>
  <p>Do you have any idea how I can solve the problem (without disrupting everything maybe)?
  Thanks</p>