Lars Mertens Lars Mertens - 10 months ago 113
AngularJS Question

Concatenation possible in ng-model?

Just a simple question is it possible to concatenate a string called "id" inside the ng-model to variable in angularjs? Is there a way a approach like this could actually work?

This works:


This doesn't work:

ng-model='currentQuantity[id + "" +]'

Answer Source

You need to quote the string id or it will be evaluated as a scope variable


ng-model='currentQuantity[id + "" +]'


ng-model='currentQuantity["id" +]'