Currently implementing Angular 8, my objective is to utilize downloaded SVG icons through a .js library. To achieve this, I have made the necessary additions to my .angular.json
file:
"scripts": [
"node_modules/csspatternlibrary3/js/site-utils.js",
"node_modules/csspatternlibrary3/js/svg-cache.js",
"node_modules/csspatternlibrary3/js/svg-url.js"
]
Furthermore, in order for the svg icons to be accessible, the method
brandcpl.initializeAllSvgIcons();
needs to be invoked. But the question remains - should an invocation similar to the following be included somewhere?
<script type="text/javascript">
$( document ).ready(function() {
brandcpl.initializeAllSvgIcons();
});
</script>???
Upon invoking
brandcpl.initializeAllSvgIcons();
via console post app start, the newly added SVG icons become visible. However, the intention is to trigger this method during the loading phase of the application...
UPDATE
After following your suggestions:
I appended:
// included in app.module.ts under providers section: { provide: APP_INITIALIZER, useFactory: init, }
In my app.module.ts: ],
providers: [{
provide: HTTP_INTERCEPTORS,
useClass: RequestInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: ResponseInterceptor,
multi: true,
},
{
provide: APP_INITIALIZER,
useFactory: init,
},
AppService,
LocalDataService,
ValidationService,
Added:
// place above ngModule declaration or save it as a separate file.. export function init() { brandcpl.initializeAllSvgIcons(); }
In my home.component file:
import {Component, OnInit} from '@angular/core';
import {DataCenterService} from '@data-center/data-center.service';
import {Observable} from 'rxjs/internal/Observable';
export function init() {
(window as any).brandcpl.initializeAllSvgIcons();
}
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit {
hasPermissionToReview$: Observable<boolean>;
However, encountering the subsequent errors:
ERROR in ./node_modules/saucelabs/index.js
Module not found: Error: Can't resolve './lib-cov/SauceLabs' in 'C:\Users\me\Documents\intellij_workspace\comp\edp-app\node_modules\sauce
labs'
ERROR in ./node_modules/protractor/built/debugger.js
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\me\Documents\intellij_workspace\comp\edp-app\node_modules\protractor\
built'
ERROR in ./node_modules/protractor/built/taskRunner.js
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\me\Documents\intellij_workspace\comp\edp-app\node_modules\protractor\
built'
ERROR in ./node_modules/protractor/built/runner.js
...
...
Seeking clarification on my procedure missteps.