Alright, so I have been stumbling upon some issue for a long time and I would like to hear an opinion from the rest of community.
First, let\'s look at some abstract
Namespacing it on the scope is pollution. What you want to do is extract that logic into a separate function which is then injected into your Controller. i.e.
function Ctrl($scope, util) {
$scope.field = "field";
$scope.whenClicked = function() {
util();
};
}
angular.module("foo", [])
.service("anyService", function(...){...})
.factory("util", function(anyService) {
return function() {
anyService.doSmth();
};
});
Now you can unit test with mocks your Ctrl as well as "util".