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
Post a Comment