javascript - Call external js file function in Angular js controller -
i have external js file has more functions.
i need call these functions angular controller.
for example: external.js
... ... function fun() {   ...   ... } ... ...   controller: acccountcontroller.js
myapp.controller('addaccountcontroller',function ($scope,addaccountloginservices,$location,localstorageservice,$compile,toaster){    ....    ....     $scope.getloginform = function(siteid,name) {              ...             ...             fun(); // function external.js file    });     ...    ...  });   i have imported external.js before acccountcontroller.js. doesnt calling function. , have not console error this.
how achieve this... in advance.
edit: gave wrong answer, bad. following example works.
your external file should this:
var dosomething = (function () {   "use strict";    return {       test: (function () {         return 'test';       }()),       test2: (function () {         return console.log('test 2');       })    }; }());   and in controller call scripts function:
console.log(dosomething.test);   or
dosomething.test2();   i learned too, ;)
Comments
Post a Comment