matth3o matth3o - 1 year ago 105
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.

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download