javascript - AngularJS : $timeout is not a function -
i trying add delay of 2000ms using timeout method not working if try call in function(searchfunc) inside cotroller. gives error: $timeout not function . controller code :
var angularjsapp = angular.module('graphapp', ['nganimate', 'ui.bootstrap','ui.grid']); angularjsapp.controller('accordiondemoctrl', function($scope, $timeout) { $scope.searchfunc = function(search_name,$timeout) { websockettest(search_name,keyword_type); //$scope.loading = false; $timeout(function () { $scope.loading = false; }, 2000); });
you're passing $timeout
parameter function
$scope.searchfunc = function(search_name,*$timeout*
which make undefined when call function because don't pass along. removing fix issue.
scope.searchfunc = function(search_name)
you can read how works (closures) here
Comments
Post a Comment