angularjs - proper way of calling the functions during init in JavaScript -


i getting error method1 () undefined. proper way invoke method during init?

 gdmsdashboard.controller('dashboardcontroller', '$scope') {          $scope.msg = "";          (function init() {             $scope.method1 ();             method1 ();             this.method1 ();          })();          $scope.method1 = function () {            //         } } 

you need understand variable hoisting concept

just make code work this

$scope.method1 = function () {            //         } (function init() {             $scope.method1(); })(); 

Comments

Popular posts from this blog

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -