AngularJS Failed Resource GET

后端 未结 3 1826
离开以前
离开以前 2020-12-09 02:48

Does anyone know how you can check to see that a resource failed to be fetched in AngularJS?

For example:

//this is valid syntax
$scope.word = Word.g         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 03:22

    Just to answer @Adio 's question too.

    The second callback will be called when any http response code is considered to be an error by AngularJS (only response codes in [200, 300] are considered success codes). So you can have a general error handling function and don't care about the specific error. The if statement there can be used to do different actions depending on the error code, but it's not mandatory.

提交回复
热议问题