我在AngularJS应用程序中有这个:
$scope.user = {
numberValue: null
}
我有这个函数返回一个值:
$scope.formalTrainingCosts = function () {
return $scope.user.avePaynonTrainedEmployees * $scope.user.newEmployeeFormalTrainingHours;
}
我可以将该值保存到变量numberValue
,如此$scope.user.numberValue = $scope.formalTrainingCosts
吗?如果这不起作用,我还能做些什么来将函数保存到变量?
答案 0 :(得分:0)
$scope.user = {
numberValue: function() {
return $scope.user.avePaynonTrainedEmployees * $scope.user.newEmployeeFormalTrainingHours;
}
}
或
$scope.user = {
numberValue: $scope.formalTrainingCosts()
}