My task involves retrieving data from a webservice using AngularJS, with the data arriving in JSON format.
Below is an excerpt from my JavaScript file:
//getzonebyid
$http.get('/zone.asmx/zone', {
params: {
log: log,
pm: pm,
id: $scope.updateparam.Id
}
})
.then(function (response) {
{
$scope.gzone = response.data.zone;
console.log(response.data.zone);
}
});
In addition, I have a dropdown list as follows:
<select ng-model="uzone" ng-change="locationupd(c)">
<option ng-repeat="l in gzone" value="{{l.jzone}}">{{l.jzone}}</option>
</select>
I am facing an issue where there is an extra blank space at the top of my dropdown list. My goal is to have the first option display the initial value fetched from the database, but this extra space is causing a problem.
I've attempted to resolve this by assigning the value to
$scope.uzone = $scope.gzone[0].value;
, but unfortunately, it hasn't worked. I've been stuck on this for several days now.
The data retrieved is in JSON format:
{"zone":[{"jzone":"South"},{"jzone":"East"},{"jzone":"North"},{"jzone":"West"}]}