这个选择框正在做它应该做的事情,但由于某种原因它不再工作了。 选择框显示作为项目经理的员工。当我选择一个时,它会用它更新输入框。
过滤
app.filter('filterEmployees', function() {
return function (input) {
console.log('input: ', input);
var output = [];
if (!input instanceof Array) {
console.log('error');
return output;
}
// for all TESPM's
input.forEach(function (tespm) {
var employees = tespm.Employees;
if (!employees instanceof Array) {
console.log('error');
return output;
}
// for all employees
employees.forEach(function (employee) {
// filter
if (employee.EmployeeIsPM) {
output.push(employee.EmployeeFirstName + ' ' + employee.EmployeeLastName);
}
});
});
console.log('output: ', output);
return output;
};
});
查看
<div class="input-group">
<span class="input-group-addon">J. TESPM</span>
<input style="width:150px" ng-model="TESPM" class="form-control" type="text">
<span class="input-group-addon">J. TESPM</span>
<select class="form-control" ng-options="empl for empl in jobArray|filterEmployees" ng-model="TESPM">
<option value="" disabled>Select</option>
</select>
</div>
控制台出错
{TypeError: undefined is not a function
at g.<anonymous> (http://localhost:44301/MyScripts/app.js:215:15)
at e (http://localhost:44301/Scripts/angular.min.js:155:305)
at Ia.| (http://localhost:44301/Scripts/angular.min.js:143:226)
at u.constant (http://localhost:44301/Scripts/angular.min.js:154:182)
at h [as $render] (http://localhost:44301/Scripts/angular.min.js:190:25)
at Object.<anonymous> (http://localhost:44301/Scripts/angular.min.js:172:335)
at g.$digest (http://localhost:44301/Scripts/angular.min.js:98:177)
at g.$apply (http://localhost:44301/Scripts/angular.min.js:101:12)
at http://localhost:44301/Scripts/angular.min.js:17:415
at Object.d [as invoke] (http://localhost:44301/Scripts/angular.min.js:30:328)
{input:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
output: []
input: Object {}
过滤器中的第215行是
// for all TESPM's
input.forEach(function (tespm) {