I have below code, now let's assume I want to call foo(val)
function from somewhere outside, let's say browser console.
angular.module('app', []);
angular.module('app')
.controller('MyController', MyController);
function MyController() {
var self = this;
self.foo = function(val) {
console.log(val);
};
return self;
}
Below code works only when foo() is bound to $scope.
angular.element(document.getElementById('MyController')).scope().foo('Hello');
Is there any work around or I will be forced to use $scope
for this ?