user3618922
user3618922

Reputation: 181

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?

Upvotes: 0

Views: 37

Answers (1)

Edwin Dalorzo
Edwin Dalorzo

Reputation: 78639

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.

Upvotes: 1

Related Questions