【发布时间】:2018-08-29 16:13:49
【问题描述】:
我想根据页面上两个字段的组合自动填充日期字段。
主页是Institution,在这个主页中我有一个员工子部分。我想看小节中的 2 个字段,我试过这段代码,但它不起作用。
$scope.$watch(function () { return vm.institution.employees.length }, function () {
_.forEach(vm.institution.employees, function (item, index) {
$scope.$watch(vm.institution.employees[index].occupation,vm.institution.employees[index].salary, function (newValue, oldValue) {
if (newValue[0] != oldValue[0]) {
vm.xx = 'test';
}
},true);
});
});
在同一机构页面员工子部分中,我正在使用下面的代码观看单个属性,它工作正常,但观看 2 不工作。
$scope.$watch(function () { return vm.institution.employees.length }, function () {
_.forEach(vm.institution.employees, function (item, index) {
debugger;
item.employeeDesignation = _.filter(vm.desginations, { id: item.designationTypeId });
$scope.$watch(function () { return vm.institution.employees[index].designationTypeId }, function (newValue, oldValue) {
if (newValue != oldValue) {
item.employeeDesignation = _.filter(vm.desginations, { id: newvalue });
}
});
});
});
【问题讨论】:
标签: javascript .net angularjs angularjs-scope