Question

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?

Was it helpful?

Solution

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();
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top