While declaring a function in the $rootscope has it's advantages, we can also declare a $scope function any part of the code that is injected by the $scope service. Controller, for instance.
Controller
myApp.controller('myController', ['$scope', function($scope){
$scope.myFunction = function ...