Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/playground/src/http/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ng_module(
# TODO: FW-1004 Type checking is currently not complete.
type_check = False,
deps = [
"//packages/common/http",
"//packages/core",
"//packages/http",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"@npm//rxjs",
Expand Down
17 changes: 9 additions & 8 deletions modules/playground/src/http/app/http_comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@
* 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';

interface Person {
Comment thread
CaerusKaru marked this conversation as resolved.
name: string;
}

@Component({
selector: 'http-app',
template: `
<h1>people</h1>
<ul class="people">
<li *ngFor="let person of people">
hello, {{person['name']}}
hello, {{person.name}}
</li>
</ul>
`
})
export class HttpCmp {
people: Object[];
constructor(http: Http) {
http.get('./people.json')
.pipe(map((res: Response) => res.json()))
.subscribe((people: Array<Object>) => this.people = people);
people: Person[];
constructor(http: HttpClient) {
http.get('./people.json').subscribe((people: Person[]) => this.people = people);
}
}
5 changes: 3 additions & 2 deletions modules/playground/src/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down
2 changes: 1 addition & 1 deletion modules/playground/src/jsonp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ng_module(
# TODO: FW-1004 Type checking is currently not complete.
type_check = False,
deps = [
"//packages/common/http",
"//packages/core",
"//packages/http",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
],
Expand Down
14 changes: 9 additions & 5 deletions modules/playground/src/jsonp/app/jsonp_comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@
* 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';

interface Person {
name: string;
}

@Component({
selector: 'jsonp-app',
template: `
<h1>people</h1>
<ul class="people">
<li *ngFor="let person of people">
hello, {{person['name']}}
hello, {{person.name}}
</li>
</ul>
`
})
export class JsonpCmp {
people: Object;
constructor(jsonp: Jsonp) {
jsonp.get('./people.json?callback=JSONP_CALLBACK').subscribe(res => this.people = res.json());
people: Person[];
constructor(http: HttpClient) {
http.jsonp('./people.json', 'callback').subscribe(res => this.people = res);
}
}
8 changes: 6 additions & 2 deletions modules/playground/src/jsonp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down
2 changes: 1 addition & 1 deletion modules/playground/src/jsonp/people.json
Original file line number Diff line number Diff line change
@@ -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"}])