Reputation: 100010
I have this code:
<div ng-repeat="c in q.children | orderBy:[]">
<div ng-if="c.kind == 'text'">
<label>
{{c.value}}
<textarea ng-model="q.newResponse.value['{{c._id}}']"></textarea>
</label>
</div>
// ...
What I am trying to do is bind a property on newReponse.value
, where that property is dynamic and is the c._id
value, so something like:
newResponse.value.44PkfeoakfoAf5o3r3773oZS3a = 'foo bar baz';
This doesn't work as is, and I get this error:
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 22 of the expression [q.newResponse.value[{{c._id}}]] starting at [{c._id}}]].
http://errors.angularjs.org/1.6.1/$parse/syntax?p0=%7B&p1=invalid%20key&p2=22&p3=q.newResponse.value%5B%7B%7Bc._id%7D%7D%5D&p4=%7Bc._id%7D%7D%5D
at angular.js:68
at AST.throwError (angular.js:14893)
at AST.object (angular.js:14882)
Is this possible and what is the right way to do this?
Upvotes: 0
Views: 421
Reputation: 100010
Nevermind, that wasn't so hard -
<div ng-if="c.kind == 'text'">
<label>
{{c.value}}
<textarea ng-model="q.newResponse.value[c._id]"></textarea>
</label>
</div>
Upvotes: 1