Eg 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 can see that the muFunc is not inside the script block but inside the Angular controller . You cannot call it directl.
But the function 'a' is normal javascript function so you call it directly .
call a and open browser console , you can see "hiiii" printed
THere are ways to expose angular function outside f the angular module but its not straight forward
Angular2 - how to call component function from outside the app
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…