我在选项标签中使用ng-repeat来生成多个选项。 但它运作不正常。
//下面是我的Angular js代码
$http.get("assign_leads_1.php?dummydata=2").then(function (response)
{
alert(response.data);
$scope.bdes = response.data;
});
Below is the html code
<div class="form-group">
<label>Assign To: </label>
<select ng-model="bde_tuid" class="form-control">
<option ng-repeat="bde in bdes" value="{{bde.tuid}}" >
{{bde.xyz}}
</option>
</select>
//下面是从数据库中获取数据的php代码
require_once 'dbcon.php';
$query ="select tuid,username as xyz from tuser where category
='employee'";
$result= mysqli_query($link, $query);
$data = array();
while($row = mysqli_fetch_array($result))
{
$data[]=$row;
}
print json_encode($data);
}
答案 0 :(得分:0)
更改此行
<option ng-repeat="bde in bdes" value="{{bde.tuid}}" >
到
<option ng-repeat="bde in bdes track by $index" value="{{bde.tuid}}" >