Just attach a selector to your DOM element where your controller is defined. like
<div ng-app="myApp" ng-controller="myCtrl" id="myCtrl">
and from anywhere you can call this controller function like
angular.element('#myCtrl').scope().resetName()
OR
angular.element(document.querySelector('#myCtrl')).scope().resetName()
In some case you need to modify a object value of controller you can do it in simple way. Just use
angular.element(document.querySelector('#myCtrl')).scope().title = 'test';
Note : Please don't forget to apply
the changes because now angular will not trigger apply
automatically. You need to trigger apply
manually. Just put below line after updating values in object/s
angular.element(document.querySelector('#myCtrl')).scope().apply();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…