简体   繁体   中英

Angular JS and getting values from a function

I have these functions that do calculations of values from input fields using ng-model.

 $scope.EmployeeCompetenceObs = function () {
      return $scope.user.percentEmployeesCompetentAfterTraining - $scope.user.percentEmployeesCompetentBeforeTraining;
  }

and what I am trying to do is get the value from that function and use it in another function:

$scope.EmployeeCompetenceAtt = function () {
      return EmployeeCompetenceObs() - $scope.user.adjustmentFactorsEmployeeCompetence;
  }

but when I call {{EmployeeCompetenceAtt()}} it comes up ad undefined...what am i doing wrong?

The EmployeeCompetenceObs is a function in the $scope , as you declared it, so you should invoke it by doing:

$scope.EmployeeCompetenceObs()

You omitted that part in your invocation and that is most likely the cause of the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM