Angular $q .catch() method fails in IE8

前端 未结 3 829
旧时难觅i
旧时难觅i 2021-01-31 08:52

I\'m experiencing a weird bug on IE8 while trying to catch a promise reject (promise returned by a basic ngResource call) :

This code work with .then(

3条回答
  •  孤独总比滥情好
    2021-01-31 09:40

    Yes, IE8 thinks it's a keyword. You can get around this a couple of ways:

    1. promise.then(function() { })['catch'](function() { });
    2. promise.then(function() { /* success handler */ })).then(null, function() { /* error handler */ });
    3. Or combine success and error into one then statement, if such a thing is appropriate: promise.then(function() { /* success handler here */ }, function() { /* error handler here */ });

    catch is shorthand for #2.

提交回复
热议问题