I have an angularjs controller. I added a function to it's scope, since this function is called from the html.
$scope.search = function() {
//do something
};
But I need to call this function from inside my controller too. I can do this by either calling
$scope.search();
or
this.search();
Both work. It's clear form me that it works, calling on the $scope
, but why does it work calling on this
? As far as I understand, the $scope
is a dedicated object.
Also, what's the preferred way of calling the function from within the controller?