Reputation: 109
I have a select dropdown which display the name of states.The data is getting fetched from php and is also available in controller JS file.But this data is appearing as blank in HTML.THe fetched result from php , shows the name of all states in table if consoled.log() is used.
HTML:
<select class='form-control' name='state' id='state' ng-model='AddqueryArr.state' required='required' ng-change='getCity(AddqueryArr.state)'>
<option></option>
<option ng-repeat='state in State.json' value='{{state.id}}'>{{state.name}}</option>
</select>
JS:
servicePOST.send(appConstants.BASE_MS_URL + 'Activity/fetch-addquery.php?case=State').then(function(result) {
$scope.State=result;
console.log($scope.State);
});
PHP:
case "State":
$sql="select stateid,statename from state ";
$result = mysql_query($sql) or die(mysql_error());
$json_array=$obj->runQuery($result);
break;
Sample Output:
Console.log:
Upvotes: 0
Views: 112
Reputation: 2731
In your Response Object you have statename
and stateid
not name
and id
.
Change your HTML as :
<select class='form-control' name='state' id='state' ng-model='AddqueryArr.state' required='required' ng-change='getCity(AddqueryArr.state)'>
<option></option>
<option ng-repeat='state in State.json' value='{{state.stateid}}'>{{state.statename}}</option>
</select>
Upvotes: 2