我建立了一个看起来像这样的表格:
$scope.users = {EmpLst : [
{
EmpName: "",
EmpNumber: "",
ExamResultList: [
]
}
]};
这是我的HTML代码:
<div ng-repeat="emp in user.EmpLst track by $index">
<div class="col-md-12" style="margin-bottom: 5px;" ng-hide="viewMode">
<div class="form-group">
<div class="col-md-1">
<label class="control-label">Emp:</label>
</div>
<div class="col-md-4">
<select ng-disabled="viewMode" name="item90display" ng-model="emp" class="form-control" ng-options="em as em.EmpName for fab in allEmp track by em.EmpNumber">
</select>
</div>
<div class="col-md-5">
<ui-select multiple ng-model="emp.ExamResultList" title="Choose a examp" on-select="console.log($item, $model)">
<ui-select-match placeholder="Select Exam...">{{$item.EmpName}}</ui-select-match>
<ui-select-choices repeat="option in allExamResult | propsFilter: {EmpName: $select.search, ExamResult: $select.search}">
<div ng-bind-html="option.EmpName | highlight: $select.search"></div>
<small>
{{option.EmpName}} {{option.ExamResult}}
</small>
</ui-select-choices>
</ui-select>
</div>
</div>
</div>
</div>
每次单击“添加”按钮时,我正在执行以下方法:
$scope.AddFabSoldtoEmptyObj = function () {
$scope.user.EmpLst.push({
EmpName: "",
EmpNumber: "",
ExamResultList: []
});
}
变量声明:
$scope.user.EmpLst = [
{
EmpName: "",
EmpNumber: "",
ExamResultList: []
}
];
然后,所有先前的值都已删除,现在EmpLst包含相同数量的对象,但是它们都是空的。
这可能是什么原因?
请注意,HTML代码位于标签内。
非常感谢助手。