Skip to content

Commit

Permalink
fix(icon-registry): throw proper error if HttpClient is missing (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil147 authored and GitHub Enterprise committed Feb 5, 2021
1 parent ab72287 commit 86c6f69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/ng-aquila/src/icon/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The filled option should only be used with **product** icons.

### Register icons service

Custom icons can be registered via the `NxIconRegistry` injectable service. With the `NxIconRegistry` you can associate icon names with SVG, URL and HTML strings and define a CSS font class.
Custom icons can be registered via the `NxIconRegistry` injectable service. With the `NxIconRegistry` you can associate icon names with SVG, URL and HTML strings and define a CSS font class. When you are registering an icon by URL please make sure to import the `HttpClientModule` from `@angular/common/http`.

<!-- example(icon-registry) -->

4 changes: 4 additions & 0 deletions projects/ng-aquila/src/icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class NxSvgIconFromUrl extends NxSvgIcon {
throw Error(`The URL provided to NxIconRegistry was not trusted as a resource URL ` +
`via Angular's DomSanitizer. Attempted URL was "${safeUrl}".`);
}
if (!this._httpClient) {
throw Error('Could not find HttpClient provider for using a SVG url in the nx-icon registry. ' +
'Please include the HttpClientModule from @angular/common/http in your app imports.');
}
}

/** Returns the content. If the SVG is not already loaded it fetches the SVG from icons' URL */
Expand Down

0 comments on commit 86c6f69

Please sign in to comment.