npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-dynamic-json-form-material

v1.0.4

Published

NGX Dynamic JSON Forms Core is a library to easily generate forms for Angular based on JSON.

Downloads

59

Readme

ngx-dynamic-json-form-material

The easy way to generate JSON based forms with angular.

Quick Start

This is the UI material package for ngx-dynamic-json-form.

Without ngx-dynamic-json-form-core this library is not usable. So please take care to install it too.

Versions

Install and Usage

This is a step by step instruction to install and use ngx-dynamic-json-form-material.

1. Install all packages:

npm i ngx-dynamic-json-form-core ngx-dynamic-json-form-material ngx-mat-select-search --save

Please make sure, that @angular/forms and "@angular/material are already installed.

2. Add ngx-dynamic-json-form-material

The forRoot() method call is required on root level.

This method is used to override default configurations and is needed to register custom components.

More information can be found in the global configuration section in the docs.

2.1. to your AppModule (Module based)

import { NgxDynamicJsonFormMaterialModule } from "ngx-dynamic-json-form-material";

@NgModule({
  imports: [
    // ...
    NgxDynamicJsonFormMaterialModule.forRoot(),
  ],
  // ...
})
export class AppModule {}

2.2. to your appConfig.ts (Standalone Version)

import { NgxDynamicJsonFormMaterialModule } from "ngx-dynamic-json-form-material";

export const appConfig: ApplicationConfig = {
  providers: [
    importProvidersFrom(NgxDynamicJsonFormMaterialModule.forRoot()),
    // ...
  ],
};

Hint: Don't forget to add NgxDynamicJsonFormMaterialModule in your standalone component as well.

import { NgxDynamicJsonFormMaterialModule } from "ngx-dynamic-json-form-material";

@Component({
  // ...
  standalone: true,
  imports: [CommonModule, NgxDynamicJsonFormMaterialModule], // <- Must Have
  changeDetection: ChangeDetectionStrategy.OnPush, // <- Recommended
})
export class MyStandaloneComponent {
  // ...
}

3. Configure the form in the component TS

@Component({
  // ...
  changeDetection: ChangeDetectionStrategy.OnPush, // <- Recommended
})
export class MyComponent implements OnInit {
  public form: FormGroup = new FormGroup({}); // <- The form instance

  // The form fields
  public fields: FormField[] = [
    {
      type: "select",
      key: "language",
      label: "Language",
      options: [
        { label: "Language 1", value: "1" },
        // ...
      ],
    },
  ];

  // The callback method to get the instance of the form
  public setForm(form: FormGroup): void {
    this.form = form;
  }
}

4. Use ngx-dynamic-json-form in the component HTML

<ngx-dynamic-json-form [fields]="fields" (getForm)="setForm($event)" [initial]="initialValues" formClassName="my-form-class"></ngx-dynamic-json-form>