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

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

Maven Javadoc 'Cannot find default setter' and fails -