Anas Bennis Anas Bennis - 1 year ago 150
AngularJS Question

Dynamic ng-model name in AngularJS

I have a problem with inputs that are generated dynamically.
How can I get their values?

<p ng-repeat="(key, value) in selectedTemplate.attributes.Params.attributes">
{{key}} : <tr><input ng-model="params[key]" type="text" placeholder="{{value}}" >

//attributes are like this
"attributes": {
"End Date": "java.sql.Timestamp",
"Containers": "java.lang.Object",
"Begin Date": "java.sql.Timestamp"


Answer Source

Just declare $scope.params = {} in your controller. and after that you can access the values by : $scope.params['End Date'], $scope.params['Containers'], $scope.params['Begin Date']