无法加载显示Json数据

时间:2015-11-24 10:10:56

标签: javascript angularjs

我有一个选择下拉列表,显示状态名称。数据是从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}}

示例输出:Sample Output

CONSOLE.LOG:

Console

1 个答案:

答案 0 :(得分:2)

在您的回复对象中,您有statenamestateid而非nameid
将您的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>