A small component to easily bind [JSON-LD](https://developers.google.com/search/docs/guides/intro-structured-data) schema to Angular templates.
npm install ngx-json-ldTo install this library, run:
``bash`
$ npm install ngx-json-ld --save
and then from your Angular AppModule:
`typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import library module
import { NgxJsonLdModule } from 'ngx-json-ld';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Register module
NgxJsonLdModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
Once the library is imported, you can use the ngx-json-ld component.
`typescript
@Component({
selector: 'app',
template: `
})
class AppComponent {
schema = {
'@context': 'http://schema.org',
'@type': 'WebSite',
'name': 'angular.io',
'url': 'https://angular.io'
};
}
`xml``
MIT © Cory Rylan