本节要解决的问题
发起请求并处理响应。
核心要点
- $http.get / post 返回 Promise
- then 处理成功失败
- 可配置拦截器
$http.get("/api/users").then(function (res) {\n $scope.users = res.data;\n});老项目的 $http 不支持 async/await,注意写法差异。
本文根据 W3School AngularJS 教程 的知识点重新整理、补充示例编写,非原文转载。
发起请求并处理响应。
发起请求并处理响应。
$http.get("/api/users").then(function (res) {\n $scope.users = res.data;\n});老项目的 $http 不支持 async/await,注意写法差异。
本文根据 W3School AngularJS 教程 的知识点重新整理、补充示例编写,非原文转载。