Function inside the AngularJS Controller

Viewed 96784

I have code snippet in which there is a Angular Modular Controller, but there is a function inside the same controller and with a call, which is raising doubt in my mind that is this way of coding allowed in Javascript or Angular? If Yes then how does it read it? See the below code format I have:

obj.controller('CartController',function($scope){

  $scope.totalCart = function(){
    var total = 10;     
    return total;
  }
  function calculate(){
    ...Some Logic..
  }

  $scope.$watch($scope.totalCart, calculate);
)};

Please help me to understand that is this type of function definition and call within a controller allowed in Angular/Javascript?

3 Answers
Related