matth3o matth3o - 3 months ago 27
Dart Question

dart angular2 - access map value component in template

I'd like to know if there is a way to write something like :


in my template.

Thanks for your help.


The problem with your code is that ['myKey'] is evaluated even when myObject is null. This would require ?[] but that is not supported

<span>{{myObject?.myField != null ? myObject.myField['myKey'] : null}}</span>


<span *ngIf="myObject?.myField != null">{{myObject.myField['myKey']}}</span>

Maybe this works as well (don't remember)

<span *ngIf="myObject?.myField">{{myObject.myField['myKey']}}</span>