44 * The http module provides services to perform http requests. To get started, see the {@link Http}
55 * class.
66 */
7- import { bind , Binding } from 'angular2/core' ;
7+ import { provide , Provider } from 'angular2/core' ;
88import { Http , Jsonp } from './src/http/http' ;
99import { XHRBackend , XHRConnection } from './src/http/backends/xhr_backend' ;
1010import { JSONPBackend , JSONPBackend_ , JSONPConnection } from './src/http/backends/jsonp_backend' ;
@@ -40,18 +40,18 @@ export {URLSearchParams} from './src/http/url_search_params';
4040/**
4141 * Provides a basic set of injectables to use the {@link Http} service in any application.
4242 *
43- * The `HTTP_BINDINGS ` should be included either in a component's injector,
43+ * The `HTTP_PROVIDERS ` should be included either in a component's injector,
4444 * or in the root injector when bootstrapping an application.
4545 *
4646 * ### Example ([live demo](http://plnkr.co/edit/snj7Nv?p=preview))
4747 *
4848 * ```
4949 * import {bootstrap, Component, NgFor, View} from 'angular2/angular2';
50- * import {HTTP_BINDINGS , Http} from 'angular2/http';
50+ * import {HTTP_PROVIDERS , Http} from 'angular2/http';
5151 *
5252 * @Component ({
5353 * selector: 'app',
54- * bindings : [HTTP_BINDINGS ]
54+ * providers : [HTTP_PROVIDERS ]
5555 * })
5656 * @View ({
5757 * template: `
@@ -83,11 +83,11 @@ export {URLSearchParams} from './src/http/url_search_params';
8383 * .catch(err => console.error(err));
8484 * ```
8585 *
86- * The primary public API included in `HTTP_BINDINGS ` is the {@link Http} class.
87- * However, other bindings required by `Http` are included,
86+ * The primary public API included in `HTTP_PROVIDERS ` is the {@link Http} class.
87+ * However, other providers required by `Http` are included,
8888 * which may be beneficial to override in certain cases.
8989 *
90- * The bindings included in `HTTP_BINDINGS ` include:
90+ * The providers included in `HTTP_PROVIDERS ` include:
9191 * * {@link Http}
9292 * * {@link XHRBackend}
9393 * * `BrowserXHR` - Private factory to create `XMLHttpRequest` instances
@@ -96,38 +96,38 @@ export {URLSearchParams} from './src/http/url_search_params';
9696 *
9797 * There may be cases where it makes sense to extend the base request options,
9898 * such as to add a search string to be appended to all URLs.
99- * To accomplish this, a new binding for {@link RequestOptions} should
100- * be added in the same injector as `HTTP_BINDINGS `.
99+ * To accomplish this, a new provider for {@link RequestOptions} should
100+ * be added in the same injector as `HTTP_PROVIDERS `.
101101 *
102102 * ### Example ([live demo](http://plnkr.co/edit/aCMEXi?p=preview))
103103 *
104104 * ```
105- * import {bind , bootstrap} from 'angular2/angular2';
106- * import {HTTP_BINDINGS , BaseRequestOptions, RequestOptions} from 'angular2/http';
105+ * import {provide , bootstrap} from 'angular2/angular2';
106+ * import {HTTP_PROVIDERS , BaseRequestOptions, RequestOptions} from 'angular2/http';
107107 *
108108 * class MyOptions extends BaseRequestOptions {
109109 * search: string = 'coreTeam=true';
110110 * }
111111 *
112- * bootstrap(App, [HTTP_BINDINGS, bind (RequestOptions).toClass( MyOptions)])
112+ * bootstrap(App, [HTTP_PROVIDERS, provide (RequestOptions, {asClass: MyOptions} )])
113113 * .catch(err => console.error(err));
114114 * ```
115115 *
116116 * Likewise, to use a mock backend for unit tests, the {@link XHRBackend}
117- * binding should be bound to {@link MockBackend}.
117+ * provider should be bound to {@link MockBackend}.
118118 *
119119 * ### Example ([live demo](http://plnkr.co/edit/7LWALD?p=preview))
120120 *
121121 * ```
122- * import {bind , Injector} from 'angular2/angular2';
123- * import {HTTP_BINDINGS , Http, Response, XHRBackend, MockBackend} from 'angular2/http';
122+ * import {provide , Injector} from 'angular2/angular2';
123+ * import {HTTP_PROVIDERS , Http, Response, XHRBackend, MockBackend} from 'angular2/http';
124124 *
125125 * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
126126 *
127127 * var injector = Injector.resolveAndCreate([
128- * HTTP_BINDINGS ,
128+ * HTTP_PROVIDERS ,
129129 * MockBackend,
130- * bind (XHRBackend).toAlias( MockBackend)
130+ * provide (XHRBackend, {asAlias: MockBackend} )
131131 * ]);
132132 * var http = injector.get(Http);
133133 * var backend = injector.get(MockBackend);
@@ -150,34 +150,40 @@ export {URLSearchParams} from './src/http/url_search_params';
150150 * });
151151 * ```
152152 */
153- export const HTTP_BINDINGS : any [ ] = [
153+ export const HTTP_PROVIDERS : any [ ] = [
154154 // TODO(pascal): use factory type annotations once supported in DI
155155 // issue: https://github.com/angular/angular/issues/3183
156- bind ( Http )
157- . toFactory ( ( xhrBackend , requestOptions ) => { return new Http ( xhrBackend , requestOptions ) ; } ,
158- [ XHRBackend , RequestOptions ] ) ,
156+ provide ( Http ,
157+ {
158+ asFactory : ( xhrBackend , requestOptions ) => new Http ( xhrBackend , requestOptions ) ,
159+ deps : [ XHRBackend , RequestOptions ]
160+ } ) ,
159161 BrowserXhr ,
160- bind ( RequestOptions ) . toClass ( BaseRequestOptions ) ,
161- bind ( ResponseOptions ) . toClass ( BaseResponseOptions ) ,
162+ provide ( RequestOptions , { asClass : BaseRequestOptions } ) ,
163+ provide ( ResponseOptions , { asClass : BaseResponseOptions } ) ,
162164 XHRBackend
163165] ;
164166
167+ /**
168+ * @deprecated
169+ */
170+ export const HTTP_BINDINGS = HTTP_PROVIDERS ;
165171
166172/**
167- * Provides a basic set of bindings to use the {@link Jsonp} service in any application.
173+ * Provides a basic set of providers to use the {@link Jsonp} service in any application.
168174 *
169- * The `JSONP_BINDINGS ` should be included either in a component's injector,
175+ * The `JSONP_PROVIDERS ` should be included either in a component's injector,
170176 * or in the root injector when bootstrapping an application.
171177 *
172178 * ### Example ([live demo](http://plnkr.co/edit/vmeN4F?p=preview))
173179 *
174180 * ```
175181 * import {Component, NgFor, View} from 'angular2/angular2';
176- * import {JSONP_BINDINGS , Jsonp} from 'angular2/http';
182+ * import {JSONP_PROVIDERS , Jsonp} from 'angular2/http';
177183 *
178184 * @Component ({
179185 * selector: 'app',
180- * bindings : [JSONP_BINDINGS ]
186+ * providers : [JSONP_PROVIDERS ]
181187 * })
182188 * @View ({
183189 * template: `
@@ -202,11 +208,11 @@ export const HTTP_BINDINGS: any[] = [
202208 * }
203209 * ```
204210 *
205- * The primary public API included in `JSONP_BINDINGS ` is the {@link Jsonp} class.
206- * However, other bindings required by `Jsonp` are included,
211+ * The primary public API included in `JSONP_PROVIDERS ` is the {@link Jsonp} class.
212+ * However, other providers required by `Jsonp` are included,
207213 * which may be beneficial to override in certain cases.
208214 *
209- * The bindings included in `JSONP_BINDINGS ` include:
215+ * The providers included in `JSONP_PROVIDERS ` include:
210216 * * {@link Jsonp}
211217 * * {@link JSONPBackend}
212218 * * `BrowserJsonp` - Private factory
@@ -215,37 +221,37 @@ export const HTTP_BINDINGS: any[] = [
215221 *
216222 * There may be cases where it makes sense to extend the base request options,
217223 * such as to add a search string to be appended to all URLs.
218- * To accomplish this, a new binding for {@link RequestOptions} should
219- * be added in the same injector as `JSONP_BINDINGS `.
224+ * To accomplish this, a new provider for {@link RequestOptions} should
225+ * be added in the same injector as `JSONP_PROVIDERS `.
220226 *
221227 * ### Example ([live demo](http://plnkr.co/edit/TFug7x?p=preview))
222228 *
223229 * ```
224- * import {bind , bootstrap} from 'angular2/angular2';
225- * import {JSONP_BINDINGS , BaseRequestOptions, RequestOptions} from 'angular2/http';
230+ * import {provide , bootstrap} from 'angular2/angular2';
231+ * import {JSONP_PROVIDERS , BaseRequestOptions, RequestOptions} from 'angular2/http';
226232 *
227233 * class MyOptions extends BaseRequestOptions {
228234 * search: string = 'coreTeam=true';
229235 * }
230236 *
231- * bootstrap(App, [JSONP_BINDINGS, bind (RequestOptions).toClass( MyOptions)])
237+ * bootstrap(App, [JSONP_PROVIDERS, provide (RequestOptions, {asClass: MyOptions} )])
232238 * .catch(err => console.error(err));
233239 * ```
234240 *
235241 * Likewise, to use a mock backend for unit tests, the {@link JSONPBackend}
236- * binding should be bound to {@link MockBackend}.
242+ * provider should be bound to {@link MockBackend}.
237243 *
238244 * ### Example ([live demo](http://plnkr.co/edit/HDqZWL?p=preview))
239245 *
240246 * ```
241- * import {bind , Injector} from 'angular2/angular2';
242- * import {JSONP_BINDINGS , Jsonp, Response, JSONPBackend, MockBackend} from 'angular2/http';
247+ * import {provide , Injector} from 'angular2/angular2';
248+ * import {JSONP_PROVIDERS , Jsonp, Response, JSONPBackend, MockBackend} from 'angular2/http';
243249 *
244250 * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
245251 * var injector = Injector.resolveAndCreate([
246- * JSONP_BINDINGS ,
252+ * JSONP_PROVIDERS ,
247253 * MockBackend,
248- * bind (JSONPBackend).toAlias( MockBackend)
254+ * provide (JSONPBackend, {asAlias: MockBackend} )
249255 * ]);
250256 * var jsonp = injector.get(Jsonp);
251257 * var backend = injector.get(MockBackend);
@@ -268,15 +274,21 @@ export const HTTP_BINDINGS: any[] = [
268274 * });
269275 * ```
270276 */
271- export const JSONP_BINDINGS : any [ ] = [
277+ export const JSONP_PROVIDERS : any [ ] = [
272278 // TODO(pascal): use factory type annotations once supported in DI
273279 // issue: https://github.com/angular/angular/issues/3183
274- bind ( Jsonp )
275- . toFactory (
276- ( jsonpBackend , requestOptions ) => { return new Jsonp ( jsonpBackend , requestOptions ) ; } ,
277- [ JSONPBackend , RequestOptions ] ) ,
280+ provide ( Jsonp ,
281+ {
282+ asFactory : ( jsonpBackend , requestOptions ) => new Jsonp ( jsonpBackend , requestOptions ) ,
283+ deps : [ JSONPBackend , RequestOptions ]
284+ } ) ,
278285 BrowserJsonp ,
279- bind ( RequestOptions ) . toClass ( BaseRequestOptions ) ,
280- bind ( ResponseOptions ) . toClass ( BaseResponseOptions ) ,
281- bind ( JSONPBackend ) . toClass ( JSONPBackend_ )
286+ provide ( RequestOptions , { asClass : BaseRequestOptions } ) ,
287+ provide ( ResponseOptions , { asClass : BaseResponseOptions } ) ,
288+ provide ( JSONPBackend , { asClass : JSONPBackend_ } )
282289] ;
290+
291+ /**
292+ * @deprecated
293+ */
294+ export const JSON_BINDINGS = JSONP_PROVIDERS ;
0 commit comments