Skip to content
This repository was archived by the owner on Mar 10, 2018. It is now read-only.
/ ngx-json-ld Public archive

📝 A small component to easily bind JSON-LD schema to Angular templates.

Notifications You must be signed in to change notification settings

coryrylan/ngx-json-ld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bd5c970 · Mar 10, 2018

History

14 Commits
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 10, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018
Mar 2, 2018

Repository files navigation

This project has moved and can now be found here.

ngx-json-ld

A small component to easily bind JSON-LD schema to Angular templates.

Installation

To install this library, run:

$ npm install ngx-json-ld --save

and then from your Angular AppModule:

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 { }

Component

Once the library is imported, you can use the ngx-json-ld component.

@Component({
  selector: 'app',
  template: `<ngx-json-ld [json]="schema"></ngx-json-ld>`
})
class AppComponent {
  schema = {
    '@context': 'http://schema.org',
    '@type': 'WebSite',
    'name': 'angular.io',
    'url': 'https://angular.io'
  };
}

Output

<ngx-json-ld>
  <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "name": "angular.io",
      "url": "https://angular.io"
    }
  </script>
</ngx-json-ld>

License

MIT © Cory Rylan