First of all, this should work, and probably the reason is that it is not, because you do not have these functions in the field. Do you have ng-controller in this element or ancestor?
If you do this, make sure that these functions are defined in the scope:
.controller("MainCtrl", function($scope){ $scope.function1 = function(){...}; $scope.function2 = function(){...}; });
Secondly, you should not use ng-init to call functions at all.
<div ng-controller="MainCtrl"> </div>
Instead, call these functions in the controller:
.controller("MainCtrl", function($scope){ function1(); function2(); function function1(){...}; function function2(){...}; });
From the Angular documentation on ngInit :
The only suitable use of ngInit is to smooth out the special properties of ngRepeat, as shown in the demo below. Other than this case, you should use controllers instead of ngInit to initialize values ββin the scope.
source share