Example page:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myCtrl">
<p>Click the button to run a function:</p>
<button ng-click="myFunc()">OK</button>
<p>The button has been clicked {{count}} times.</p>
</div>
<script>
a=function(){
console.log("hiii")
}
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
$scope.count = 0;
$scope.myFunc = function() {
$scope.count++;
};
}]);
</script>
</body>
</html>
You may notice that the `myFunc` is not located inside the script block but within the Angular controller. It cannot be called directly.
However, the function 'a' is a regular JavaScript function so it can be called directly.
Execute `a` and check the browser console for the output "hiiii."
There are methods to expose an Angular function outside of the Angular module, but it is not a simple process.
Angular2 - how to call component function from outside the app