🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ngx-golden-layout-2

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-golden-layout-2

This library allows for Angular 12+ applications to easily use [Golden Layout](http://golden-layout.com/).

latest
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

NgxGoldenLayout2

This library allows for Angular 12+ applications to easily use Golden Layout.

Why version 2?

The package ngx-golden-layout has fallen out of maintenance and is now 4 major releases behind Angular and 2 major releases behind GoldenLayout. The package is also close sourced.

Demo

To see this package in action, run:

npm i && npm start

Setup

  • Install this package
npm i ngx-golden-layout-2 golden-layout
  • Add NgxGoldenLayout to your app module
@NgModule({
  declarations: [...],
  imports: [NgxGoldenLayoutModule.forRoot()], // Add this line
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {
  ...
}
  • Register all your Ng components with NgxGoldenLayoutModule in AppModule.

import {
  NgxGoldenLayoutModule,
  GoldenLayoutManagerService,
} from "ngx-golden-layout-2";

@NgModule({
  ... 
  imports: [NgxGoldenLayoutModule.forRoot()],
  ...
})
export class AppModule {
  constructor(private _goldenLayoutManagerService: GoldenLayoutManagerService) {
    this._goldenLayoutManagerService.registerComponentTypes([
      { name: TextComponent.name, componentType: TextComponent },
      { name: ColorComponent.name, componentType: ColorComponent },
      { name: BooleanComponent.name, componentType: BooleanComponent },
    ]);
  }
}
  • To your AppComponent (or the component you wish to use GoldenLayout in) set the host component:
import {
  GoldenLayoutHostComponent,
  GoldenLayoutManagerService,
} from "ngx-golden-layout-2";

@Component({
  template: `
      <golden-layout-host #goldenLayoutHost></golden-layout-host>   
  `,
})
export class AppComponent implements AfterViewInit {
  @ViewChild("goldenLayoutHost")
  private _goldenLayoutHostComponent: GoldenLayoutHostComponent;

  constructor(
    private _goldenLayoutManagerService: GoldenLayoutManagerService
  ) {}

  ngAfterViewInit() {
    this._goldenLayoutManagerService.setGoldenLayoutHostComponent(
      this._goldenLayoutHostComponent
    );
  }
}
  • Add your components to the GoldenLayout host via...

    this._goldenLayoutManagerService.addComponent(componentType);

FAQs

Package last updated on 13 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts