Getting Started

The OneSchema Angular package contains an Angular module to help embed OneSchema into your application


You can install this package with npm:

npm i --save @oneschema/angular @oneschema/importer

Sample usage

To use the package, add the OneSchemaModule to your module:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

// Import the module from the OneSchema package
import { OneSchemaModule } from '@oneschema/angular';

  declarations: [AppComponent],
  imports: [

    // Import the module into the application, with configuration
      clientId: 'CLIENT_ID',
      templateKey: 'TEMPLATE_KEY',
      userJwt: 'USER_JWT',
      styles: {
         position: 'fixed',
         top: '0',
         left: '0',
         width: '100vw',
         height: '100vh',
         zIndex: 1000,

  bootstrap: [AppComponent],
export class AppModule {}

Then, you can test the module with the included OneSchema button component:


Or make your own component using the OneSchema service:

import { Component } from '@angular/core'
import { OneSchemaService } from './oneschema.service'

  selector: 'oneschema-button',
  template: `<button (click)="launch()">Open OneSchema</button>`,
  styles: [],
export class OneSchemaButton implements OnDestroy {
  constructor(public oneschema: OneSchemaService) {
    this.oneschema.on('success', this.onSuccess)
    this.oneschema.on('error', this.onError)
    this.oneschema.on('cancel', this.onCancel)

  launch() {

  onSuccess(data: any) {
    // handle success

  onError(message: string) {
    // handle error

  onCancel() {
    // handle cancel

  ngOnDestroy() {'success', this.onSuccess)'error', this.onError)'cancel', this.onCancel)

To style the iframe, either pass in styles prop to the module, add CSS to your global stylesheet, or to a component with ViewEncapsulation.None. The iframe's class will be what is passed to the module as the className prop or oneschema-iframe by default. Sample CSS for the iframe to take up the full viewport is:

.oneschema-iframe {
  position: fixed;
  right: 0;
  top: 0;
  width: 100vw;
  height: 100vh;

Advanced usage

Custom iframe

To manage the iframe inside your application, pass manageDOM option as false to the OneSchemaModule and then create an iframe component:

import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'
import { OneSchemaService } from '@oneschema/angular'

  selector: 'oneschema-iframe',
  template: ` <iframe #oneschema></iframe>`,
  styles: [
      iframe {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
export class OneSchemaIframe implements AfterViewInit {
  @ViewChild('oneschema') iframe?: ElementRef<HTMLIFrameElement>

  constructor(public oneschema: OneSchemaService) {}

  ngAfterViewInit() {

API Reference

Table of Contents


The OneSchemaModule provides access to the OneSchemaService and OneSchemaButton. It uses the singleton forRoot pattern to setup the service. It accepts one object of params for the service as parameters


TypeObject (OneSchemaParams)
DescriptionThe parameters given to OneSchemaModule at initialization


The OneSchemaService is provided by the OneSchemaModule. It is an instance of the OneSchemaImporterClass.


The OneSchemaButton is a sample component which includes a button that will open the OneSchema importer. To include use this in your template: