Skip to content

Commit 9a6d26e

Browse files
danielsoglIgorMinar
authored andcommitted
docs: refactor pipe example to use the HttpClient (angular#22741)
PR Close angular#22741
1 parent 6a797d5 commit 9a6d26e

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

aio/content/examples/pipes/src/app/app.module.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
// #docregion
2+
import { HttpClientModule } from '@angular/common/http';
23
import { NgModule } from '@angular/core';
3-
import { BrowserModule } from '@angular/platform-browser';
44
import { FormsModule } from '@angular/forms';
5-
import { HttpClientModule } from '@angular/common/http';
5+
import { BrowserModule } from '@angular/platform-browser';
66

77
import { AppComponent } from './app.component';
8-
import {
9-
FlyingHeroesComponent,
10-
FlyingHeroesImpureComponent
11-
} from './flying-heroes.component';
8+
import { ExponentialStrengthPipe } from './exponential-strength.pipe';
9+
import { FetchJsonPipe } from './fetch-json.pipe';
10+
import { FlyingHeroesComponent, FlyingHeroesImpureComponent } from './flying-heroes.component';
11+
import { FlyingHeroesImpurePipe, FlyingHeroesPipe } from './flying-heroes.pipe';
1212
import { HeroAsyncMessageComponent } from './hero-async-message.component';
1313
import { HeroBirthdayComponent } from './hero-birthday1.component';
1414
import { HeroBirthday2Component } from './hero-birthday2.component';
1515
import { HeroListComponent } from './hero-list.component';
16-
import { PowerBoosterComponent } from './power-booster.component';
1716
import { PowerBoostCalculatorComponent } from './power-boost-calculator.component';
18-
import {
19-
FlyingHeroesPipe,
20-
FlyingHeroesImpurePipe
21-
} from './flying-heroes.pipe';
22-
import { FetchJsonPipe } from './fetch-json.pipe';
23-
import { ExponentialStrengthPipe } from './exponential-strength.pipe';
17+
import { PowerBoosterComponent } from './power-booster.component';
18+
2419

2520
@NgModule({
2621
imports: [
@@ -43,6 +38,6 @@ import { ExponentialStrengthPipe } from './exponential-strength.pipe';
4338
FetchJsonPipe,
4439
ExponentialStrengthPipe
4540
],
46-
bootstrap: [ AppComponent ]
41+
bootstrap: [AppComponent]
4742
})
4843
export class AppModule { }

aio/content/examples/pipes/src/app/fetch-json.pipe.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// #docregion
2-
import { Pipe, PipeTransform } from '@angular/core';
32
import { HttpClient } from '@angular/common/http';
3+
import { Pipe, PipeTransform } from '@angular/core';
4+
45
// #docregion pipe-metadata
56
@Pipe({
67
name: 'fetch',
78
pure: false
89
})
910
// #enddocregion pipe-metadata
10-
export class FetchJsonPipe implements PipeTransform {
11+
export class FetchJsonPipe implements PipeTransform {
1112
private cachedData: any = null;
1213
private cachedUrl = '';
1314

@@ -17,7 +18,7 @@ export class FetchJsonPipe implements PipeTransform {
1718
if (url !== this.cachedUrl) {
1819
this.cachedData = null;
1920
this.cachedUrl = url;
20-
this.http.get(url).subscribe( result => this.cachedData = result );
21+
this.http.get(url).subscribe(result => this.cachedData = result);
2122
}
2223

2324
return this.cachedData;

0 commit comments

Comments
 (0)