我有一个选择下拉列表,显示状态名称。数据是从php获取的,也可以在控制器JS文件中找到。但是这些数据在HTML中显示为空白。从php获取结果,显示名称如果使用consoled.log(),则表中的所有状态。
HTML:
servicePOST.send(appConstants.BASE_MS_URL + 'Activity/fetch-addquery.php?case=State').then(function(result) {
$scope.State=result;
console.log($scope.State);
});
JS:
case "State":
$sql="select stateid,statename from state ";
$result = mysql_query($sql) or die(mysql_error());
$json_array=$obj->runQuery($result);
break;
PHP:
{{1}}
示例输出:
CONSOLE.LOG:
答案 0 :(得分:2)
在您的回复对象中,您有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>