Reputation: 129
I have a function sendData()
. My question is can it get executed without invoking it, inside the controller?
Upvotes: 0
Views: 67
Reputation: 16541
No, but you can call it just after declaration.
var sendData = function() {
//dostuff
}
sendData();
Upvotes: 1
Reputation: 10132
You can wrap your method in self execution name function.
var sendData = (function _() {
// your stuff
return _;
})();
It will directly executes and you can also later call it using sendData()
Upvotes: 1