Reputation: 588
<ng-model="formData.alert_settings.{{alert}}" ng-repeat="alert in alerts">
I wanted ng-model names to be formData.alert_settings.down
, formData.alert_settings.up
, etc.
where :
alerts={down,up,trouble , ...}
This way formData.alert_settings.{{alert}}
is not working.
Please help me.
Upvotes: 1
Views: 2026
Reputation: 2506
If you have this in your controller:
$scope.formData = {alert_settings: {}}
$scope.alerts=['down','up','trouble'];
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
Upvotes: 7
Reputation: 3712
You should use:
ng-model="formData.alert_settings.alert
Upvotes: 0