Call external js file function in Angular js controller

I have similar situation and I did not have to make it self invoking function. Including the external js file into the html and it worked fine.


EDIT: gave wrong answer, my bad. the following example works.

your external file should like this:

var doSomething = (function () {
  "use strict";
   return {
      test: (function () {
        return 'test';
      }()),
      test2: (function () {
        return console.log('test 2');
      })
   };
}());

and in your controller you call your scripts function:

console.log(doSomething.test);

or

doSomething.test2();

i learned something too, thanks ;)


As mentioned by @nilsK, you define a self invoking function. And then reference to it via window object. For example -

(function functionName(){
    Do Something Here...
})();

And then,

window.functionName();

And if your are using AngularJS,

$window.functionName();