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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -