Jan Jan - 1 year ago 77
AngularJS Question

Use ng-repeat variable inside ng-model names

<ng-model="formData.alert_settings.{{alert}}" ng-repeat="alert in alerts">

I wanted ng-model names to be
, etc.

where :

alerts={down,up,trouble , ...}

This way
is not working.
Please help me.

Answer Source

If you have this in your controller:

$scope.formData = {alert_settings: {}}

Then you can do this

<input type="text" ng-model="formData.alert_settings[alert]" ng-repeat="alert in alerts">

and you will end up with three inputs and the data will be in formData.alert_settings.down, and so on

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