Ede Ede - 3 months ago 37
AngularJS Question

Can I reuse the key from ng-repeat in a model?

I'm trying to reuse the key from the ng-repeat for the model of the input field ng-model="...key.percent".

Something like this:

<div ng-repeat="(key, val) in $ctrl.offer.properties">
<fieldset ng-if="val">
<input name="procent" ng-model="$ctrl.offer.properties.key.procent"/>

I want to keep my properties as they are.

Is there a way to do this?


Sure, you can access it via key by wrapping key inside [] like below.