Jan Kowalski Jan Kowalski - 1 year ago 72
AngularJS Question

How to concat 2 expressions in interpolate

I have directive where I want to render a list from various objects.


$scope.propertyName = 'price';


<div ng-repeat="item in obj">
<a>{{ 'item.' + propertyName }}</a>

will have various properties and I can't use static property name.

{{ 'item.' + propertyName }}
return string
- I want expression like
{{ item.price }}

Answer Source

Just like you would do in JavaScript:

{{ item[propertyName] }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download