Armin Mesicpersonal blog

You can also bind functions to$scopenot just variables and you can call these with the curly notation ``, it will be executed every time the digest cycle starts.

Let’s assume you need to calculate the sum of$scope.val1and$scope.val2every time one of these two changes.


$scope.val1 = 1;
$scope.val2 = 99;

$scope.getSum = function() {
  // To be 100% sure that number is returned not just concatinated strings
  return parseInt($scope.val1) + parseInt($scope.val2);


The sum is \{\{getSum()\}\}