Seeking assistance with an issue in Angular: the select control is not initially choosing the correct value but updates on subsequent changes. I am new to Angular, and my HTML code looks like this:
<select class="form-control" ng-model="job.SalutationId" ng-init="job.SalutationId=0">
<option value="0">Salutation</option>
<option ng-repeat="salutation in lookups.salutations" value="{{salutation.Id}}">{{salutation.Name}}</option>
</select>
I'm loading an object via WebApi representing a job and lookup values. The JavaScript function for loading the job data is as follows:
function loadJob() {
$http({ method: 'GET', url: url + 'jobs/2' }).
then(function (response) {
$scope.lookups.salutations = response.data.Salutations;
$scope.job = response.data.Job;
}, function (response) {
displayJobErrorMessage(response.data || "Request failed");
});
}
Although the job.SalutationId
is set correctly, the select option does not automatically choose the correct value. Any advice on where I might be going wrong would be greatly appreciated.
Thank you,
Carl