arkon / ng-inline-svg

[Inactive] Angular directive for inserting an SVG file inline within an element.
https://echeung.me/ng-inline-svg/
MIT License
210 stars 88 forks source link

svgService.setBaseUrl - Expected 0 arguments, but got 1 #82

Closed joeypx closed 6 years ago

joeypx commented 6 years ago

I appreciate ng-inline-svg very much, thank you!

Trying to implement it along with Universal in Angular 6 and your Release 8.0.0, I ran into an error. Is there missing the argument in your svg-cache.service.ts?

app-load.service.ts

import { Injectable } from '@angular/core';
import { SVGCacheService } from 'ng-inline-svg';
import { AppConfig } from '../_config/index';

@Injectable()
export class AppLoadService {
    constructor(
        public svgService: SVGCacheService,
        public appConfig: AppConfig
    ) { }

    initializeApp() {
        // Set baseURL
        this.svgService.setBaseUrl({ baseUrl: this.appConfig.baseUrl });
    }
}

Throws the error

ERROR in src/app/_services/app-load.service.ts(14,9): error TS2554: Expected 0 arguments, but got 1.

Peeking into the definition, it seems the function is not supposed to receive arguments...

Thank you very much for your reply.

Joey

arkon commented 6 years ago

I think #81 might have "broken" this since it's now expected to be passed in when you initialize the module. Would it be possible to do it from your module?

joeypx commented 6 years ago

Thanks for the super fast reply and the hint. Working like a charm - resolved as follows:

import { environment } from '../environments/environment';

@NgModule({
    ...,
    imports: [
        ...,
        InlineSVGModule.forRoot({ baseUrl: environment.baseUrl })
    ],
    ...
})

Cheers, Joey