I have a simple AngularJS form that is connected to the database.
The form displays list of names and country of birth on an HTML table:
<table class="table table-bordered" style="max-width: 100%;" id="myAreas">
<tr ng-repeat="name in Names">
<td>{{name.FullName}}</td>
<td>
<select ng-model="selectedCountryForEdit" ng-show="editMode">
<option ng-repeat="z in countryList" value="{{z.CountryCode}}">{{z.CountryName}}</option>
</select>
<span style="display: block;" ng-show="!editMode">{{areaItem.Countries}}</span>
</td>
<td><a href="" ng-click="editMode = !editMode"><i class="fa fa-pencil" aria-hidden="true"></i></a></td>
</tr>
</table>
The table use the following JS/Angular code:
$http.get('/Home/GetNames')
.then(function (response) {
$scope.Names = response.data;
})
.catch(function (e) {
console.log("error", e);
throw e;
})
.finally(function () {
console.log("This finally block");
});
And the JS/Angular is calling a method on MVC to list data from the database.
I don't want to include the MVC code because it is working fine and my issue relies on something else:
If look at the html table, there is a pencil icon with each row that allows me to display a dropdown menu instead of the country.
What I am doing is filling the drop-down menu with list of countries from the database and I want the dropdown menu display the same country of the selected row/name.
I searched a lot and I could not find how to solve this issue. I am very new to Angular and JS and I hope you can advise on this.