In Angular, you can define methods in your controller by attaching them to $scope
:
$scope.myFunction = function () { ... }
Of course, you can also attach them to this
, which I've seen used for communicating between directives and a parent controller:
/* within the controller */
this.myFunction = function () { ... }
Are there performance differences between the two approaches due to Angular watching the values?
Even if there aren't performance differences, it seems like a nice way of keeping some methods private, so they won't accidentally be accessed from the View.