There are several ways, but to be honest, this seems like more effort than its value, as you can simply do:
scope.getGUID = AppUtilities.getGUID;
Of course, you can use $rootScope , but for me it personally seems wrong - I like it when things are explicitly declared and do not magically appear.
Alternatively, if you just need to display the GUID in the user interface, create a GUID directive. For instance:
.directive("guid", function(){ return { template: "<span>{{getGUID()}}</span>", link: function(scope, element, attrs){ scope.getGUID = function(){ return AppUtilities.getGUID(attrs.guid || attrs.name); }; } } });
and use as:
<h4 class="guid"><guid name="goal"></guid></h4>
source share