Ede Ede - 1 year ago 74
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?

Answer Source

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

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