javascript - Angularjs $timeout not executing -


i'm new angularjs , want add timer once page load. read number of similar kind of questions here still couldn't resolve issue. added data-ng-init="init()" view. controller:

    'use strict';      angular.module('tempapp')       .controller('maincontroller',['$scope','$timeout','dservice', function ($scope,$timeout, dservice) {          $scope.init =  function(){             console.log("safety checkstatus page load");             $timeout(callattimeout(),3000);         }       function callattimeout(){         console.log("safety checkstatus ***");     }   }]); 

jsfiddle: https://jsfiddle.net/zusee/s6xy48t0/9/

here dservice separate service js file i'm going use. appreciated.

you can try this?

'use strict';      angular.module('tempapp')       .controller('maincontroller',['$scope','$timeout','dservice', function ($scope,$timeout, dservice) {         $scope.init =  function(){              console.log("safety checkstatus page load");              $timeout(function () {                   $scope.callattimeout();             }, 1000);         }           $scope.callattimeout = function(){            console.log("safety checkstatus ***");        }         $scope.init();  }]); 

Comments