3

I need a way to set a timeout before the ng-click is triggered, something like:

window.setTimeout("ng-click='myCtrl.myFunction()', 1000")

I don't think it is possibile but I really need to have this kind of effect. I have a very particular animated button, when it is clicked it has to call a function in my controller, but that function has to be invoked only when the buttons animation is finished. (I can't use setTimeout() or something like that inside the function because it keeps the button pressed, and my function has to be executed after the button "get up").

10
  • window.setTimeout("ng-click=myCtrl.myFunction()", 1000) Commented Mar 23, 2016 at 18:33
  • 1
    $timeout? Commented Mar 23, 2016 at 18:35
  • @RajaprabhuAravindasamy nope, already tried, no error but not working. Commented Mar 23, 2016 at 18:38
  • @AlonEitan I don't think this is possible, my view don't know what it is $timeout, right? Commented Mar 23, 2016 at 18:40
  • @Giulio No it doesn't - You need to put the code inside the $timeout callback function in your controller Commented Mar 23, 2016 at 18:41

1 Answer 1

0

SOLVED

A user solved the problem but he have deleted his answer, anyway, here is the solution:

$scope.clickOnUpload = function () {
  $timeout(function() {
    angular.element('#myselector').triggerHandler('click');
  }, 100);
};
Sign up to request clarification or add additional context in comments.

2 Comments

I would like but I can't, when I try it says: "You can accept your own answer in 2 days"
Ok sorry, didn't know that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.