I would to display JSON data in html input fields using AngularJS. Here's the code.
I have two HTML files. First HTML file contains a table which displays the json data. When you click in a row then it opens a modal window with a form (second HTML file).
Here's the Code: JSON data
var examples = [
{ 'id': '1', 'fname': 'john' },
{ 'id': '2', 'fname': 'bonnie' },
{ 'id': '3', 'fname': 'joey' }
];
Here's the Code: (First HTML file)
...
<tr ng-repeat="item in examples" ng-click="open(this.item)">
<td>{{ item.id }}</td>
<td>{{ item.fname }}</td>
</tr>
...
Second HTML file:
...
<input type="text" class="form-control" placeholder="ID" id="firstVal" value="">
...
My Controller:
...
$scope.open = function (item) {
console.log(item.id);
$("#firstVal").val(item.id);
};
...
It doesn't insert the value "id" in the input field. How can I do this with AngularJS or jQuery?? In the console I'm getting the value of id.
ng-modelto the<input ... />and set its value