0

According to this https://github.com/angular/angular.js/issues/1159

this should work, shouldn't it?

el.bind('keyup', function() {       
    var canceler = $q.defer();
    $http.post('/api', data, {timeout: canceler.promise}).success(success);
    canceler.resolve();
});

because it doesn't fire the request at all, no errors or anything, could it be because it's inside a bind function?

fxck
  • 4,898
  • 8
  • 56
  • 94
  • Yes, if you are running 1.1.5 or greater. Otherwise, you the other work around listed in the link you provided. – abc123 Jul 02 '13 at 19:02
  • I'm running 1.1.5 it still doesn't fire the request at all. – fxck Jul 02 '13 at 19:03
  • then i'd contact the creator (as you already did on that forum) or use the work around that is provided on that same forum post. – abc123 Jul 02 '13 at 19:05

1 Answers1

1

it indeed was because it's inside the nonangular bind() event, putting scope.$apply() after http and before resolve will fix it

https://github.com/angular/angular.js/issues/1159#issuecomment-20368490

el.bind('keyup', function() {       
    var canceler = $q.defer();
    $http.post('/api', data, {timeout: canceler.promise}).success(success);
    scope.$apply();
    canceler.resolve();
});
fxck
  • 4,898
  • 8
  • 56
  • 94