var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.name = 'World';
});

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Global Functions in AngularJs </title>
    <link rel="stylesheet" href="style.css" />
    <script src="https://code.angularjs.org/1.4.3/angular.js"></script>
    <script>
        var app = angular.module('myApp', []);

        //This is global functions for every controler.
        app.run(function ($rootScope, $window) {
            $rootScope.myGlobalFunction = function () {
                //TODO : your custom code here.
                $window.alert('I am global function. :)');
                console.log("I am global function. :)");
            };
        });

        //This is controller for accessing to global functions.
        app.controller('MainCtrl', function ($scope) {
            //TODO: your controller code here.
        });
    </script>
</head>
<body ng-app="myApp" ng-controller="MainCtrl">
    <p class="txt">Global Functions in AngularJs</p>
    <div ng-init="myGlobalFunction()">
        <p>
            <a href="http://code-sample.com/">Click for know about me. :)</a>
        </p>
        <button class="btn" ng-click="myGlobalFunction()">Click and call global function</button>
    </div>
</body>
</html>
/* Put your css in here */

.btn {
        border: 1px solid #3366FF;
        background-color: #B3C6FF;
        height:30px;
}
.txt{
        color:red;
}