我正在显示一个包含用户信息的表,在此表下方有一个输入框,用户可以输入行索引并根据行索引,使用ng-options动态填充对象。
HTML UI
填充下拉列表后
填充下拉列表后,所有标签都是未定义的。不确定是什么问题。
// html file -
async protected void Page_Load(object sender, EventArgs e)
{
await TestMethod();
}
// app.js
<html>
<head>
<title>AngularFilter</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../lib/angular.js"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="styles.css" />
</head>
<body ng-app="filter">
<div ng-controller="filterController">
<table>
<thead>
<tr>
<th>Index</th>
<th>Name</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in data">
<th>{{$index + 1}}</th>
<th>{{employee.name | lowercase}}</th>
<th>{{employee.dob | date:"dd/MM/yyyy"}}</th>
<th>{{employee.gender| uppercase}}</th>
<th>{{employee.salary | number:2}}</th>
</tr>
</tbody>
</table>
<br>
<input type="text" placeholder="Enter the index of array" ng-model="idx" ng-blur="getSelectedIndex()" />
<select ng-model="element" ng-options="{{optionString}}" >
<option value="">select option</option>
</select>
</div>
</body>
答案 0 :(得分:1)
您使用object data source
$scope.elements
作为ng-options
将$scope.optionString
更改为
$scope.optionString = "value as value for (key,value) in elements";
请参阅documentation了解对象数据源。
<强> FULL EXAMPLE 强>