Difference between revisions of "AngularJS HTTP module"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In [[AngularJS]], the Observable implements the [[Observer pattern]].
+
In [[AngularJS]], the HTTP Module provides features for communicating with servers via HTTP.
  
== Methods ==
+
== Description ==
  
* '''.subscribe''' = start and listen to an observable stream.
+
It simplifies usage of the XHR and JSONP APIs.
* '''.onNext''' = called when new data arrives.
+
* '''.onError''' = called when error is thrown.
+
* '''.onComplete''' = called when stream is completed.
+
  
== Compare with promises ==
+
The HTTP module API conveniently matches RESTful verbs.
  
Observables are similar to promises.
+
It returns an observable object.
  
== toPromise ==
+
== Observables ==
  
Observables can be converted to promises using the '''toPromise''' method.
+
See [[AngularJS observable]].
  
== Error handling ==
+
== Headers ==
  
Chain the '''.catch''' method on an Observable.
+
See [[AngularJS header]].
 
+
Pass in a callback sign a single '''error''' argument.
+
  
 
== See also ==
 
== See also ==
Line 30: Line 25:
 
== External links ==
 
== External links ==
  
* [https://angular.io/docs/ts/latest/guide/structural-directives.html Structural Directives] @ angular.io
+
* [https://angular.io/docs/ts/latest/guide/server-communication.html HTTP Client] @ angular.io
 +
* [https://angular.io/docs/ts/latest/tutorial/toh-pt6.html HTTP Tutorial] @ angular.io
  
 
[[Category:AngularJS]]
 
[[Category:AngularJS]]
 
[[Category:Web design and development]]
 
[[Category:Web design and development]]
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Latest revision as of 15:01, 2 January 2017

In AngularJS, the HTTP Module provides features for communicating with servers via HTTP.

Description

It simplifies usage of the XHR and JSONP APIs.

The HTTP module API conveniently matches RESTful verbs.

It returns an observable object.

Observables

See AngularJS observable.

Headers

See AngularJS header.

See also

External links