On my page, I have dynamically generated input tags from the database. These fields may look like this:
<input id='customField-Street' type='text' />
<input id='customField-Height' type='text' />
<input id='customField-IsBlack' type="checkbox" />
<select id='customField-Car'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
I need to find a way to set the model binding in the following key value:
$scope.customFieldsDictionary = [{
"Key": "customField-Street",
"Value": "SomeStreet"
}, {
"Key": "customField-Height",
"Value": "125"
}, {
"Key": "customField-IsBlack",
"Value": "true"
}, {
"Key": "customField-Car",
"Value": "volvo"
}];
I need to have a key format, since my service accepts user data in this format.
Question : How to establish two-way AngularJS binding between input fields and a field $scope.customFieldsDictionaryin a specified dictionary, such as a format.
source
share