[英]Can't Load display Json data
我有一個選擇下拉列表,顯示狀態名稱。從php獲取數據,也可以在控制器JS文件中使用。但是此數據在HTML中顯示為空白。從php獲取的結果顯示所有狀態的名稱如果使用consoled.log(),則在表中。
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;
樣本輸出:
Console.log:
在您的響應對象必須statename
和stateid
沒有name
和id
。
將您的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.stateid}}'>{{state.statename}}</option>
</select>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.