JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app ng-controller="Ctrl">
<div class="control-group" ng-repeat="field in customFields">
<ng-form name="myForm">
<label class="control-label">{{field}}</label>
<div class="controls">
<input id="{{field}}" name="{{field}}" type="text" data-ng-model="person.customfields[field]" required="required" /> <span class="validation_error" data-ng-show="myForm['\{\{field\}\}'].$error.required">Required!go</span>
</div>
</ng-form>
</div>
<button ng-click="collectData()">Collect</button>
</div>
JavaScript
function Ctrl($scope) {
$scope.customFields = ["Age", "Weight", "Ethnicity"];
$scope.person = {
customfields: {
"Age": 0,
"Weight": 0,
"Ethnicity": 0
}
};
$scope.collectData = function () {
console.log($scope.person.customfields);
}
}