Angular JS and Webservices

Angular JS and Webservices

本文关键字:Webservices and JS Angular      更新时间:2023-09-26

我想用Angular JS调用Web服务。我是Angular JS的新手。我有几个问题,需要你的专业知识。1)我正在使用WAMP,我是否需要使用/安装一些框架才能从Angular JS进行REST调用?2)请分享一些很好的高级教程链接。我一直得到一些与移动开发相关的教程。

谢谢尤克提

1)不,你不需要框架来进行REST调用。您只需在控制器或服务中使用$httpProvider

   $http.get('/someUrl').
  success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
  }).
  error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });

2)推荐教程:

  • http://www.bennadel.com/blog/2612-using-the-http-service-in-angularjs-to-make-ajax-requests.htm
  • https://egghead.io/lessons/angularjs-http