I have installed this package @ngx-lite/json-ld. In an attempt to make my SEO schema.org dynamic. On importing the module as specified on this Tutorial I get this error:
ERROR in src/app/app.module.ts(18,21): error TS2339: Property ‘forRoot’ does not exist on type ‘typeof NgxJsonLdModule’.
Here is my app.module
import { NgtUniversalModule } from "@ng-toolkit/universal";
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
// Third Party library
import { NgxJsonLdModule } from "@ngx-lite/json-ld";
import { AppComponent } from "./app.component";
import { AppRoutingModule } from "./app-routing.module";
@NgModule({
declarations: [AppComponent],
imports: [
AppRoutingModule,
NgtUniversalModule,
NgxJsonLdModule.forRoot()
],
providers: []
})
export class AppModule {}
I’m using angular 6.1.9 and Angular Universal.
3
Answers
This specific package (sources here) does not provide any service, so it doesn’t need a forRoot method on the import.
You can just import it like this :
By looking here :
https://github.com/coryrylan/ngx-json-ld/blob/master/lib/ngx-json-ld.module.ts
seems like there is not .forRoot() method defined for that module, so as previous comment says correct, you can just add the module and thats it!
Good luck!
maybe change .forRoot by .withConfig