88
99import { catchOperator , doOperator , finallyOperator , map , RxChain , share } from '@angular/cdk/rxjs' ;
1010import { Injectable , Optional , SecurityContext , SkipSelf } from '@angular/core' ;
11- import { Http } from '@angular/http' ;
11+ import { HttpClient } from '@angular/common /http' ;
1212import { DomSanitizer , SafeResourceUrl } from '@angular/platform-browser' ;
1313import { Observable } from 'rxjs/Observable' ;
1414import { forkJoin } from 'rxjs/observable/forkJoin' ;
@@ -32,8 +32,9 @@ export function getMatIconNameNotFoundError(iconName: string): Error {
3232 * @docs -private
3333 */
3434export function getMatIconNoHttpProviderError ( ) : Error {
35- return Error ( 'Could not find Http provider for use with Angular Material icons. ' +
36- 'Please include the HttpModule from @angular/http in your app imports.' ) ;
35+ return Error ( 'Could not find HttpClient provider for use with Angular Material icons. ' +
36+ 'Please include the HttpClientModule from @angular/common/http in your ' +
37+ 'app imports.' ) ;
3738}
3839
3940
@@ -92,7 +93,7 @@ export class MatIconRegistry {
9293 */
9394 private _defaultFontSetClass = 'material-icons' ;
9495
95- constructor ( @Optional ( ) private _http : Http , private _sanitizer : DomSanitizer ) { }
96+ constructor ( @Optional ( ) private _httpClient : HttpClient , private _sanitizer : DomSanitizer ) { }
9697
9798 /**
9899 * Registers an icon by URL in the default namespace.
@@ -442,7 +443,7 @@ export class MatIconRegistry {
442443 * cached, so future calls with the same URL may not cause another HTTP request.
443444 */
444445 private _fetchUrl ( safeUrl : SafeResourceUrl ) : Observable < string > {
445- if ( ! this . _http ) {
446+ if ( ! this . _httpClient ) {
446447 throw getMatIconNoHttpProviderError ( ) ;
447448 }
448449
@@ -463,8 +464,7 @@ export class MatIconRegistry {
463464
464465 // TODO(jelbourn): for some reason, the `finally` operator "loses" the generic type on the
465466 // Observable. Figure out why and fix it.
466- const req = RxChain . from ( this . _http . get ( url ) )
467- . call ( map , response => response . text ( ) )
467+ const req = RxChain . from ( this . _httpClient . get ( url , { responseType : 'text' } ) )
468468 . call ( finallyOperator , ( ) => this . _inProgressUrlFetches . delete ( url ) )
469469 . call ( share )
470470 . result ( ) ;
@@ -476,15 +476,19 @@ export class MatIconRegistry {
476476
477477/** @docs -private */
478478export function ICON_REGISTRY_PROVIDER_FACTORY (
479- parentRegistry : MatIconRegistry , http : Http , sanitizer : DomSanitizer ) {
480- return parentRegistry || new MatIconRegistry ( http , sanitizer ) ;
479+ parentRegistry : MatIconRegistry , httpClient : HttpClient , sanitizer : DomSanitizer ) {
480+ return parentRegistry || new MatIconRegistry ( httpClient , sanitizer ) ;
481481}
482482
483483/** @docs -private */
484484export const ICON_REGISTRY_PROVIDER = {
485- // If there is already an MatIconRegistry available, use that. Otherwise, provide a new one.
485+ // If there is already an MdIconRegistry available, use that. Otherwise, provide a new one.
486486 provide : MatIconRegistry ,
487- deps : [ [ new Optional ( ) , new SkipSelf ( ) , MatIconRegistry ] , [ new Optional ( ) , Http ] , DomSanitizer ] ,
487+ deps : [
488+ [ new Optional ( ) , new SkipSelf ( ) , MatIconRegistry ] ,
489+ [ new Optional ( ) , HttpClient ] ,
490+ DomSanitizer
491+ ] ,
488492 useFactory : ICON_REGISTRY_PROVIDER_FACTORY
489493} ;
490494
0 commit comments