From e1fc44f5d6cf7a586313454b4ced99731dce6591 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Jan 2020 20:52:32 -0600 Subject: [PATCH] build: remove @angular/http from modules (#34892) PR Close #34892 --- modules/playground/src/http/BUILD.bazel | 2 +- modules/playground/src/http/app/http_comp.ts | 9 +++------ modules/playground/src/http/index.ts | 5 +++-- modules/playground/src/jsonp/BUILD.bazel | 2 +- modules/playground/src/jsonp/app/jsonp_comp.ts | 6 +++--- modules/playground/src/jsonp/index.ts | 8 ++++++-- modules/playground/src/jsonp/people.json | 2 +- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/modules/playground/src/http/BUILD.bazel b/modules/playground/src/http/BUILD.bazel index 3aced90ee0..a4e36e30b7 100644 --- a/modules/playground/src/http/BUILD.bazel +++ b/modules/playground/src/http/BUILD.bazel @@ -7,8 +7,8 @@ ng_module( srcs = glob(["**/*.ts"]), tsconfig = "//modules/playground:tsconfig-build.json", deps = [ + "//packages/common/http", "//packages/core", - "//packages/http", "//packages/platform-browser", "//packages/platform-browser-dynamic", "@npm//rxjs", diff --git a/modules/playground/src/http/app/http_comp.ts b/modules/playground/src/http/app/http_comp.ts index 4a1be633d0..719e52b433 100644 --- a/modules/playground/src/http/app/http_comp.ts +++ b/modules/playground/src/http/app/http_comp.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import {HttpClient} from '@angular/common/http'; import {Component} from '@angular/core'; -import {Http, Response} from '@angular/http'; -import {map} from 'rxjs/operators'; @Component({ selector: 'http-app', @@ -23,9 +22,7 @@ import {map} from 'rxjs/operators'; }) export class HttpCmp { people: Object[]; - constructor(http: Http) { - http.get('./people.json') - .pipe(map((res: Response) => res.json())) - .subscribe((people: Array) => this.people = people); + constructor(http: HttpClient) { + http.get('./people.json').subscribe((people: Array) => this.people = people); } } diff --git a/modules/playground/src/http/index.ts b/modules/playground/src/http/index.ts index 19672e8b54..4ddec0a89b 100644 --- a/modules/playground/src/http/index.ts +++ b/modules/playground/src/http/index.ts @@ -6,14 +6,15 @@ * found in the LICENSE file at https://angular.io/license */ +import {HttpClientModule} from '@angular/common/http'; import {NgModule} from '@angular/core'; -import {HttpModule} from '@angular/http'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {HttpCmp} from './app/http_comp'; -@NgModule({declarations: [HttpCmp], bootstrap: [HttpCmp], imports: [BrowserModule, HttpModule]}) +@NgModule( + {declarations: [HttpCmp], bootstrap: [HttpCmp], imports: [BrowserModule, HttpClientModule]}) export class ExampleModule { } diff --git a/modules/playground/src/jsonp/BUILD.bazel b/modules/playground/src/jsonp/BUILD.bazel index 0a399f0273..f9807ef4de 100644 --- a/modules/playground/src/jsonp/BUILD.bazel +++ b/modules/playground/src/jsonp/BUILD.bazel @@ -7,8 +7,8 @@ ng_module( srcs = glob(["**/*.ts"]), tsconfig = "//modules/playground:tsconfig-build.json", deps = [ + "//packages/common/http", "//packages/core", - "//packages/http", "//packages/platform-browser", "//packages/platform-browser-dynamic", ], diff --git a/modules/playground/src/jsonp/app/jsonp_comp.ts b/modules/playground/src/jsonp/app/jsonp_comp.ts index 46e111acf7..6559378fd7 100644 --- a/modules/playground/src/jsonp/app/jsonp_comp.ts +++ b/modules/playground/src/jsonp/app/jsonp_comp.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import {HttpClient} from '@angular/common/http'; import {Component} from '@angular/core'; -import {Jsonp} from '@angular/http'; @Component({ selector: 'jsonp-app', @@ -22,7 +22,7 @@ import {Jsonp} from '@angular/http'; }) export class JsonpCmp { people: Object; - constructor(jsonp: Jsonp) { - jsonp.get('./people.json?callback=JSONP_CALLBACK').subscribe(res => this.people = res.json()); + constructor(http: HttpClient) { + http.jsonp('./people.json', 'callback').subscribe((res: Object) => this.people = res); } } diff --git a/modules/playground/src/jsonp/index.ts b/modules/playground/src/jsonp/index.ts index c9e6501b8a..0a4fc469b9 100644 --- a/modules/playground/src/jsonp/index.ts +++ b/modules/playground/src/jsonp/index.ts @@ -6,14 +6,18 @@ * found in the LICENSE file at https://angular.io/license */ +import {HttpClientJsonpModule, HttpClientModule} from '@angular/common/http'; import {NgModule} from '@angular/core'; -import {JsonpModule} from '@angular/http'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {JsonpCmp} from './app/jsonp_comp'; -@NgModule({bootstrap: [JsonpCmp], declarations: [JsonpCmp], imports: [BrowserModule, JsonpModule]}) +@NgModule({ + bootstrap: [JsonpCmp], + declarations: [JsonpCmp], + imports: [BrowserModule, HttpClientModule, HttpClientJsonpModule] +}) export class ExampleModule { } diff --git a/modules/playground/src/jsonp/people.json b/modules/playground/src/jsonp/people.json index 764beb25d7..9d4b4de2ad 100644 --- a/modules/playground/src/jsonp/people.json +++ b/modules/playground/src/jsonp/people.json @@ -1,2 +1,2 @@ // This can only be requested once due to constant method name :( -__ng_jsonp__.__req0.finished([{"name":"caitp"}]) +ng_jsonp_callback_0([{"name":"caitp"}])