Giter Club home page Giter Club logo

angular2-json-schema-form's Introduction

Angular JSON Schema Form

npm version npm downloads GitHub MIT License Dependencies devDependencies

A JSON Schema Form builder for Angular 4 and 5, similar to, and mostly API compatible with,

Note: This is currently a personal proof-of-concept project, and is not affiliated with any of the organizations listed above. (Though they are all awesome, and totally worth checking out.)

Breaking change in version 0.7.0-alpha.1 and above

You must now import both JsonSchemaFormModule and a framework module. (Don't worry, it's easy.) For full details, see 'To install from NPM and use in your own project', below.

Check out the live demo and play with the examples

Check out some examples here.

This example playground features over 70 different JSON Schemas for you to try (including all examples used by each of the three libraries listed above), and the ability to quickly view any example formatted with Material Design, Bootstrap 3, Bootstrap 4, or without any formatting.

Installation

To install from GitHub

To install the library and the example playground from GitHub, clone https://github.com/dschnelldavis/angular2-json-schema-form.git with your favorite git program. Or, assuming you have git and Node/NPM installed, enter the following in your terminal:

git clone https://github.com/dschnelldavis/angular2-json-schema-form.git angular2-json-schema-form
cd angular2-json-schema-form
npm install
npm start

This should start a server with the example playground, which you can view in your browser at http://localhost:4200

All the source code is in the /src folder. Inside that folder, you will find the following sub-folders:

  • lib/src - Angular JSON Schema Form main library
  • lib/src/framework-library - framework library
  • lib/src/widget-library - widget library
  • lib/src/shared - various utilities and helper functions
  • demo - the demonstration playground example application
  • demo/assets/example-schemas - JSON Schema examples used in the playground

If you want detailed documentation describing the individual functions used in this library, run npm run docs to generate TypeDoc documentation, and then look in the generated /docs/api folder. (Angular JSON Schema Form is still a work in progress, so right now this documentation varies from highly detailed to completely missing.)

To install from NPM and use in your own project

If, after playing with the examples, you decide this library is functional enough to use in your own project, you can install it from NPM using either NPM or Yarn. To install with NPM, run the following from your terminal:

npm install angular2-json-schema-form

Then import JsonSchemaFormModule in your main application module, like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import {
  JsonSchemaFormModule, MaterialDesignFrameworkModule
} from 'angular2-json-schema-form';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule, MaterialDesignFrameworkModule,
    JsonSchemaFormModule.forRoot(MaterialDesignFrameworkModule)
  ],
  providers: [],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Note that you have to import both the main JsonSchemaFormModule and a separate framework module (in this example, MaterialDesignFrameworkModule).

The framework module is listed in your imports section twice, once by itself (to load the framework's components) and again in the JsonSchemaFormModule.forRoot() function (to load the framework's service and tell Angular JSON Schema Form to use it).

Four framework modules are currently included:

  • MaterialDesignFrameworkModule — Material Design
  • Bootstrap3FrameworkModule — Bootstrap 3
  • Bootstrap4FrameworkModule — Bootstrap 4
  • NoFrameworkModule — plain HTML (for testing)

It is also possible to load multiple frameworks and switch between them at runtime, like the example playground on GitHub. But most typical sites will just load one framework.

Seed Application Examples

For complete examples of how to install and configure Angular JSON Schema Form to work with each included display framework, check out the following seed applications:

Additional notes for Angular CLI

Make sure you are running a recent version of Angular CLI.

Very old versions of Angular CLI (e.g. 1.0.1) may fail with the error Critical dependency: the request of a dependency is an expression while trying to compile ajv (Another JSON Schema Validator). But this error has been fixed in newer versions. So if you receive that error, upgrade your Angular CLI.

Additional notes for SystemJS

If you use SystemJS, you will also need to make the following changes to your systemjs.config.js file. (If you're using a recent version of Angular CLI, or you don't have a systemjs.config.js file in your project, that means you're not using SystemJS, and you can safely ignore this section.)

Add these lines to the 'map' section of systemjs.config.js:

'angular2-json-schema-form': 'npm:angular2-json-schema-form/bundles/angular2-json-schema-form.umd.js',
'ajv':                       'npm:ajv/dist/ajv.min.js',
'lodash':                    'npm:lodash/lodash.min.js'

(Note: These instructions have not been tested recently. If you use SystemJS and have problems, please post a bug report on GitHub.)

Using Angular JSON Schema Form

Basic use

For basic use, after loading JsonSchemaFormModule as described above, to display a form in your Angular component, simply add the following to your component's template:

<json-schema-form
  loadExternalAssets="true"
  [schema]="yourJsonSchema"
  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>

Where schema is a valid JSON schema object, and onSubmit calls a function to process the submitted JSON form data. If you don't already have your own schemas, you can find a bunch of samples to test with in the src/demo/assets/example-schemas folder, as described above.

Setting loadExternalAssets="true" will automatically load any additional assets needed by the display framework. It is useful when you are trying out this library, but production sites should instead load all required assets separately. For full details see 'Changing or adding frameworks', below.

Data-only mode

Angular JSON Schema Form can also create a form entirely from a JSON object—with no schema—like so:

<json-schema-form
  loadExternalAssets="true"
  [(ngModel)]="exampleJsonObject">
</json-schema-form>
exampleJsonObject = {
  "first_name": "Jane", "last_name": "Doe", "age": 25, "is_company": false,
  "address": {
    "street_1": "123 Main St.", "street_2": null,
    "city": "Las Vegas", "state": "NV", "zip_code": "89123"
  },
  "phone_numbers": [
    { "number": "702-123-4567", "type": "cell" },
    { "number": "702-987-6543", "type": "work" }
  ], "notes": ""
};

In this mode, Angular JSON Schema Form automatically generates a schema from your data. The generated schema is relatively simple, compared to what you could create on your own. However, as the above example shows, it does detect and enforce string, number, and boolean values (nulls are also assumed to be strings), and automatically allows array elements to be added, removed, and reordered.

After displaying a form in this mode, you can also use the formSchema and formLayout outputs (described in 'Debugging inputs and outputs', below), to return the generated schema and layout, which will give you a head start on writing your own schemas and layouts by showing you examples created from your own data.

Also, notice that the 'ngModel' input supports Angular's 2-way data binding, just like other form controls, which is why it is not always necessary to use an onSubmit function.

Advanced use

Additional inputs an outputs

For more control over your form, you may provide these additional inputs:

  • layout array with a custom form layout (see Angular Schema Form's form definitions for information about how to construct a form layout)
  • data object to populate the form with default or previously submitted values
  • options object to set any global options for the form
  • widgets object to add custom widgets
  • language string to set the error message language (currently supports 'en' and 'fr')
  • framework string or object to set which framework to use

For framework, you can pass in your own custom framework object, or, if you've loaded multiple frameworks, you can specify the name of the framework you want to use. To switch between the included frameworks, use 'material-design', 'bootstrap-3', 'bootstrap-4', and 'no-framework'.

If you want more detailed output, you may provide additional functions for onChanges to read the values in real time as the form is being filled out, and you may implement your own custom validation indicators from the boolean isValid or the detailed validationErrors outputs.

Here is an example:

<json-schema-form
  [schema]="yourJsonSchema"
  [layout]="yourJsonFormLayout"
  [(data)]="yourData"
  [options]="yourFormOptions"
  [widgets]="yourCustomWidgets"
  language="fr"
  framework="material-design"
  loadExternalAssets="true"
  (onChanges)="yourOnChangesFn($event)"
  (onSubmit)="yourOnSubmitFn($event)"
  (isValid)="yourIsValidFn($event)"
  (validationErrors)="yourValidationErrorsFn($event)">
</json-schema-form>

Note: If you prefer brackets around all your attributes, the following is functionally equivalent:

<json-schema-form
[schema]="yourJsonSchema"
[layout]="yourJsonFormLayout"
[(data)]="yourData"
[options]="yourFormOptions"
[widgets]="yourCustomWidgets"
[language]="'fr'"
[framework]="'material-design'"
[loadExternalAssets]="true"
(onChanges)="yourOnChangesFn($event)"
(onSubmit)="yourOnSubmitFn($event)"
(isValid)="yourIsValidFn($event)"
(validationErrors)="yourValidationErrorsFn($event)">
</json-schema-form>

If you use this syntax, make sure to include the nested quotes ("' and '") around the language and framework names. (If you leave out the inner quotes, Angular will read them as a variable names, rather than strings, which will cause errors. All un-bracketed attributes, however, are automatically read as strings, so they don't need inner quotes.)

Single-input mode

You may also combine all your inputs into one compound object and include it as a form input, like so:

let yourCompoundInputObject = {
  schema:    { ... },  // REQUIRED
  layout:    [ ... ],  // optional
  data:      { ... },  // optional
  options:   { ... },  // optional
  widgets:   { ... },  // optional
  language:   '...' ,  // optional
  framework:  '...'    // (or { ... }) optional
}
<json-schema-form
  [form]="yourCompoundInputObject"
  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>

You can also mix these two styles depending on your needs. In the example playground, all examples use the combined form input for schema, layout, and data, which enables each example to control those three inputs, but the playground uses separate inputs for language and framework, enabling it to change those settings independent of the example.

Combining inputs is useful if you have many unique forms and store each form's data and schema together. If you have one form (or many identical forms), it will likely be more useful to use separate inputs for your data and schema. Though even in that case, if you use a custom layout, you could store your schema and layout together and use one input for both.

Compatibility modes

If you have previously used another JSON form creation library—Angular Schema Form (for AngularJS), React JSON Schema Form, or JSON Form (for jQuery)—in order to make the transition easier, Angular JSON Schema Form will recognize the input names and custom input objects used by those libraries. It should automatically work with JSON Schemas in version 6, version 4, version 3, or the truncated version 3 format supported by JSON Form. So the following will all work:

Angular Schema Form (AngularJS) compatibility:

<json-schema-form
  [schema]="yourJsonSchema"
  [form]="yourAngularSchemaFormLayout"
  [(model)]="yourData">
</json-schema-form>

React JSON Schema Form compatibility:

<json-schema-form
  [schema]="yourJsonSchema"
  [UISchema]="yourReactJsonSchemaFormUISchema"
  [(formData)]="yourData">
</json-schema-form>

JSON Form (jQuery) compatibility:

<json-schema-form
  [form]="{
    schema: yourJsonSchema,
    form: yourJsonFormLayout,
    customFormItems: yourJsonFormCustomFormItems,
    value: yourData
  }">
</json-schema-form>

Note: 2-way data binding will work with any dedicated data input, including 'data', 'model', 'ngModel', or 'formData'. However, 2-way binding will not work with the combined 'form' input.

Debugging inputs and outputs

Finally, Angular JSON Schema Form includes some additional inputs and outputs for debugging:

  • debug input — Activates debugging mode.
  • loadExternalAssets input — Causes external JavaScript and CSS needed by the selected framework to be automatically loaded from a CDN (this is not 100% reliable, so while this can be helpful during development and testing, it is not recommended for production)—Note: If you are using this mode and get a console error saying an external asset has not loaded (such as jQuery, required for Bootstrap 3) simply reloading your web browser will usually fix it.
  • formSchema and formLayout outputs — Returns the final schema and layout used to create the form (which will either show how your original input schema and layout were modified, if you provided inputs, or show you the automatically generated ones, if you didn't).
<json-schema-form
  [schema]="yourJsonSchema"
  [debug]="true"
  loadExternalAssets="true"
  (formSchema)="showFormSchemaFn($event)"
  (formLayout)="showFormLayoutFn($event)">
</json-schema-form>

Customizing

In addition to a large number of user-settable options, Angular JSON Schema Form also has the ability to load custom form control widgets and layout frameworks. All forms are constructed from these basic components. The default widget library includes all standard HTML 5 form controls, as well as several common layout patterns, such as multiple checkboxes and tab sets. The default framework library includes templates to style forms using Material Design, Bootstrap 3, or Bootstrap 4 (or plain HTML with no formatting, which is not useful in production, but can be helpful for development and debugging).

User settings

(TODO: List all available user settings, and configuration options for each.)

Creating custom input validation error messages

You can easily add your own custom input validation error messages, either for individual control widgets, or for your entire form.

Setting error messages for individual controls or the entire form

To set messages for individual form controls, add them to that control's node in the form layout, like this:

let yourFormLayout = [
  { key: 'name',
    title: 'Enter your name',
    validationMessages: {
      // Put your error messages for the 'name' field here
    }
  },
  { type: 'submit', title: 'Submit' }
]

To set messages for the entire form, add them to the form options, inside the defautWidgetOptions validationMessages object, like this:

let yourFormOptions = {
  defautWidgetOptions: {
    validationMessages: {
      // Put your error messages for the entire form here
    }
  }
}

How to format error messages

The validationMessages object—in either a layout node or the form options—contains the names of each error message you want to set as keys, and the corresponding messages as values. Messages may be in any of the following formats:

  • String: A plain text message, which is always the same.
  • String template: A text message that includes Angular template-style {{variables}}, which will be be replaced with values from the returned error object.
  • Function: A JavaScript function which accepts the error object as input, and returns a string error message.

Here are examples of all three error message types:

validationMessages: {

  // String error message
  required: 'This field is required.',

  // String template error message
  // - minimumLength variable will be replaced
  minLength: 'Must be at least {{minimumLength}} characters long.',

  // Function error message
  // - example error object:   { multipleOfValue: 0.01, currentValue: 3.456 }
  // - resulting error message: 'Must have 2 or fewer decimal places.'
  multipleOf: function(error) {
    if ((1 / error.multipleOfValue) % 10 === 0) {
      const decimals = Math.log10(1 / error.multipleOfValue);
      return `Must have ${decimals} or fewer decimal places.`;
    } else {
      return `Must be a multiple of ${error.multipleOfValue}.`;
    }
  }
}

(Note: These examples are from the default set of built-in error messages, which includes messages for all JSON Schema errors except type, const, enum, and dependencies.)

Available input validation errors and object values

Here is a list of all the built-in JSON Schema errors, which data type each error is available for, and the values in their returned error objects:

Error name Data type Returned error object values
required any (none)
type any requiredType, currentValue
const any requiredValue, currentValue
enum any allowedValues, currentValue
minLength string minimumLength, currentLength
maxLength string maximumLength, currentLength
pattern string requiredPattern, currentValue
format string requiredFormat, currentValue
minimum number minimumValue, currentValue
exclusiveMinimum number exclusiveMinimumValue, currentValue
maximum number maximumValue, currentValue
exclusiveMaximum number exclusiveMaximumValue, currentValue
multipleOf number multipleOfValue, currentValue
minProperties object minimumProperties, currentProperties
maxProperties object maximumProperties, currentProperties
dependencies * object (varies, based on dependencies schema)
minItems array minimumItems, currentItems
maxItems array maximumItems, currentItems
uniqueItems array duplicateItems
contains * array requiredItem
  • Note: The contains and dependencies validators are still in development, and do not yet work correctly.

Changing or adding widgets

To add a new widget or override an existing widget, either add an object containing your new widgets to the widgets input of the <json-schema-form> tag, or load the WidgetLibraryService and call registerWidget(widgetType, widgetComponent), with a string type name and an Angular component to be used whenever a form needs that widget type.

Example:

import { YourInputWidgetComponent } from './your-input-widget.component';
import { YourCustomWidgetComponent } from './your-custom-widget.component';
...
let yourNewWidgets = {
  input: YourInputWidgetComponent,          // Replace existing 'input' widget
  custom-control: YourCustomWidgetComponent // Add new 'custom-control' widget
}

...and...

<json-schema-form
  [schema]="yourJsonSchema"
  [widgets]="yourNewWidgets">
</json-schema-form>

...or...

import { WidgetLibraryService } from 'angular2-json-schema-form';
...
constructor(private widgetLibrary: WidgetLibraryService) { }
...
// Replace existing 'input' widget:
widgetLibrary.registerWidget('input', YourInputWidgetComponent);
// Add new 'custom-control' widget:
widgetLibrary.registerWidget('custom-control', YourCustomWidgetComponent);

To see many examples of widgets, explore the source code, or call getAllWidgets() from the WidgetLibraryService to see all widgets currently available in the library. All default widget components are in the /src/lib/src/widget-library folder, and all custom Material Design widget components are in the /src/lib/src/framework-library/material-design-framework folder. (The Bootstrap 3 and Bootstrap 4 frameworks just reformat the default widgets, and so do not include any custom widgets of their own.)

Changing or adding frameworks

To change the active framework, either use the framework input of the <json-schema-form> tag, or load the FrameworkLibraryService and call setFramework(yourCustomFramework), with either the name of an available framework ('bootstrap-3', 'bootstrap-4', 'material-design', or 'no-framework'), or with your own custom framework object, like so:

import { YourFrameworkComponent } from './your-framework.component';
import { YourWidgetComponent } from './your-widget.component';
...
let yourCustomFramework = {
  framework: YourFrameworkComponent,                                // required
  widgets:     { 'your-widget-name': YourWidgetComponent,   ... },  // optional
  stylesheets: [ '//url-to-framework-external-style-sheet', ... ],  // optional
  scripts:     [ '//url-to-framework-external-script',      ... ]   // optional
}

...and...

<json-schema-form
  [schema]="yourJsonSchema"
  [framework]="yourCustomFramework">
</json-schema-form>

...or...

import { FrameworkLibraryService } from 'angular2-json-schema-form';
...
constructor(private frameworkLibrary: FrameworkLibraryService) { }
...
frameworkLibrary.setFramework(yourCustomFramework);

The value of the required framework key is an Angular component which will be called to format each widget before it is displayed. The optional widgets object contains any custom widgets, which will override or supplement the built-in widgets. And the optional stylesheets and scripts arrays contain URLs to any additional external style sheets or JavaScript libraries required by the framework. These are the external stylesheets and scripts that will be loaded if the "loadExternalAssets" option is set to "true".

Loading external assets required by a framework

Most Web layout framework libraries (including both Bootstrap and Material Design) need additional external JavaScript and/or CSS assets loaded in order to work properly. The best practice is to load these assets separately in your site, before calling Angular JSON Schema Form. (For the included libraries, follow these links for more information about how to do this: Bootstrap and Material Design.)

Alternately, during development, you may find it helpful to let Angular JSON Schema Form load these resources for you (as wed did in the 'Basic use' example, above), which you can do in several ways:

  • Call setFramework with a second parameter of true (e.g. setFramework('material-design', true)), or
  • Add loadExternalAssets: true to your options object, or
  • Add loadExternalAssets="true" to your <json-schema-form> tag, as shown above

Finally, if you want to see what scripts a particular framework will automatically load, after setting that framework you can call getFrameworkStylesheets() or getFrameworkScritps() from the FrameworkLibraryService to return the built-in arrays of URLs.

However, if you are creating a production site you should load these assets separately, and make sure to remove all references to loadExternalAssets to prevent the assets from being loaded twice.

Two approaches to writing your own frameworks

The two built-in frameworks (in the /src/lib/src/framework-library folder) demonstrate different strategies for how frameworks can style form elements. The Bootstrap 3 and Bootstrap 4 frameworks are very lightweight and include no additional widgets (though they do load some external stylesheets and scripts). They work entirely by adding styles to the default widgets. In contrast, the Material Design framework uses the Material Design for Angular library to replace most of the default form control widgets with custom widgets from that library.

Contributions and future development

If you find this library useful, I'd love to hear from you. If you have any trouble with it or would like to request a feature, please post an issue on GitHub.

If you're a programmer and would like a fun intermediate-level Angular project to hack on, clone the library and take a look at the source code. I wrote this library both because I needed an Angular JSON Schema Form builder, and also as a way to sharpen my Angular skills. This project is just complex enough to be challenging and fun, but not so difficult as to be overwhelming. One thing I particularly like is that each example in the demo playground is like a little puzzle which provides immediate feedback—as soon as it works perfectly, you know you've solved it.

I've also tried to split things into small modules as much as possible, so even though some code is still a bit messy, most individual parts should be straightforward to work with. (A lot of the code is well commented, though some isn't—but I'm working to fix that. If you run into anything you don't understand, please ask.) If you make improvements, please submit a pull request to share what you've done.

This library is mostly functional (I'm already using it in another large site, where it works well), but it still has many small bugs to fix and enhancements that could be made. Here's a random list of some stuff I know needs to be added or improved:

  • TDD tests—The single biggest flaw in this library is that each change or improvement has the potential to break something else (which has already happened several times). Integrating automated tests into the build process would fix that.

  • More frameworks—Not everyone uses Material Design, Bootstrap 3, or Bootstrap 4, so it would be great to create framework plug-ins for Foundation 6, Semantic UI, or other web design frameworks.

  • More widgets—There are lots of great form controls available, such as the Pikaday calendar, Spectrum color picker, and ACE code editor, which just need small custom wrappers to convert them into Angular JSON Schema Form plug-ins. In addition, there are a few additional features of HTML, JSON Schema, and Material Design which could be fixed by adding new widgets:

    • A file widget—To support uploading files, this widget would display an HTML file input, and then include the uploaded file in the form's output data, as an ArrayBuffer or DataURL.

    • A oneOf widget—To support schemas using oneOf or anyOf, this widget would enable a user to choose an option from a select list, which would then replace another control on the form.

    • An addAdditionalProperties widget—To support schemas using additionalProperties or patternProperties, this widget would enable users to enter a name to add a new property to an object, and would then add a new control to the form for setting that property's value (similar to the existing add-reference widget).

    • A matStepper widget—To support the Angular Material Stepper control (similar to the existing tabs widget).

If you like this library, need help, or want to contribute, let me know. I'm busy, so it sometimes takes me a long time to respond, but I will eventually get back to you. :-)

Thanks! I hope you enjoy using this library as much as I enjoyed writing it.

License

MIT

angular2-json-schema-form's People

Contributors

blained3 avatar davepar avatar dschnelldavis avatar felschr avatar gigon avatar jessehon avatar jscharett avatar loupi avatar msbtrifork avatar rhalff avatar samuelmarks avatar stalsma avatar thorski avatar witold-gren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular2-json-schema-form's Issues

Dynamic updates

Hi, thank you for great library,

I'm trying to make an dynamic select widget (ajax or websocket powered - select with remote data for example), but when i bind data to widget, layout never updated. if i bind static data there is no problem at all, but if i bind after constructor (inside ngOnInit or setTimeout) relevant vars changing but layout never updating.

i also tried, applicationref, ChangeDetectionStrategy and ngzone but i got no result.

Some details:
I cloned library's select widget code from widgets folder and changed these lines,

constructor(
    private jsf: JsonSchemaFormService,
    private ws: webSocketRequest,
  ){

  }

  ngOnInit() {

    this.options = this.layoutNode.options;

      this.ws.webSocketRequest("info", this.options.parameters , (value: any) => {

          this.selectList = value;
          this.jsf.initializeControl(this);

      });

  }

I looked default widgets code but no result yet, so can you give more detail to make a dynamic widget?

any helps appreciated.

Problem with float number

There is an error when I tried to write a float number(example: 3,2 or 3.2), the data field was deleted.
I put property type as number.

Ionic loading controllers dismiss not working properly after latest upgrade

I am using "angular2-json-schema-form" in an ionic 3 ("ionic-angular": "3.5.0") app. After latest upgrade "angular2-json-schema-form": "^0.4.0-alpha.18", I am facing an issue with ionic's Loading Controller. On loading dismiss, loader disappears from screen, but the overlay still remains. So, I am unable to click on other elements on the page after loading dismiss.
When i disable "angular2-json-schema-form", loading controller works fine.

Last working version for me was "angular2-json-schema-form": "^0.3.0-alpha.27"

How to customized new widget?

How to customized new widget? Example:file upload?
If I customized a new widget,schema and form which one I show put customized type in?

Material-design

I try to use material design in the form.

<json-schema-form *ngIf="myData"
[form]="jsonFormObject"
[framework]="material-design"
loadExternalAssets="true"
(onSubmit)="yourOnSubmitFn($event)">

But it's not working, always used bootstrap-3.

Cannot import the module

@NgModule({
    imports: [
        AppRoutingModule,
        FlexLayoutModule,
        BrowserModule,
        HttpModule,
        MaterialModule,
        JsonSchemaFormModule,
        ...
export class AppModule {
}

But, when I try to use it in another module

<json-schema-form
    [schema]="getJsonSchema()"
    (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>

I get the following error:

'json-schema-form' is not a known element:

If I import JsonSchemaFormModule in the module I want to use it, I get that BowerModule is imported twice.

Form always invalid if has readonly attributes.

If I set readonly to true in the schema, the value is not editable but is displayed. This is correct.
But when the form is submitted, the event is always null. And when other fields are edited, the
validationErrors() is called with:
should have required property 'id'

How can I make this work?

Also, how can I make the submit button disabled if the form is invalid or unchanged?

detailSchema = {
"type": "object",
"title": "Details",
"properties": {
"name": {
"title": "Name",
"type": "string",
"description": "Item Name.",
},
"id": {
"title": "ID",
"type": "string",
"description": "ID.",
"readonly": true,
},
},
"required": [
"name",
"id",
]
};

Add button in array

I tried to change the add button in array type. I used:

form": [
{
"key": "products",
"add": "New product",
"items": [
"products[].product",
"products[].quantity",
"products[].unity",
{
"key": "products[].description",
"type": "textarea"
}
]
},
{
"type": "submit",
"style": "btn-info",
"title": "Save"
}
]

But the text in the button don't change

file upload in angularjs 2.0

Hi,
any one have sample code for upload file using anularjs2.0 with php rest service please send me the sample code for calling php rest api service and pull the file into the server.

Thanks
Rizwan

Getting typescript error upon installation

> [email protected] tsc /Users/tgautier/src/angular2-json-schema-form
> tsc

../../node_modules/@types/protractor/index.d.ts(11,34): error TS2304: Cannot find name 'webdriver'.
../../node_modules/@types/protractor/index.d.ts(12,27): error TS2304: Cannot find name 'webdriver'.
../../node_modules/@types/protractor/index.d.ts(13,32): error TS2304: Cannot find name 'webdriver'.
../../node_modules/@types/protractor/index.d.ts(14,27): error TS2304: Cannot find name 'webdriver'.
...

Darwin Kernel Version 16.3.0, node version 7.4.0, npm version 4.0.5

Error when use "@angular/material": "2.0.0-beta.2"

When I used with "@angular/material": "2.0.0-beta.2" I had the next problem

"Unhandled Promise rejection: Template parse errors:
Can't bind to 'required' since it isn't a known property of 'md-input'.

  1. If 'md-input' is an Angular component and it has 'required' input, then verify that it is part of this module.
  2. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [attr.minlength]="options?.minLength"
    [attr.pattern]="options?.pattern"
    [ERROR ->][required]="options?.required"
    [class]="options?.fieldHtmlClass"
    [disabled]="controlD"): MaterialInputComponent@8:8
    Can't bind to 'disabled' since it isn't a known property of 'md-input'.
  3. If 'md-input' is an Angular component and it has 'disabled' input, then verify that it is part of this module.
  4. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [required]="options?.required"
    [class]="options?.fieldHtmlClass"
    [ERROR ->][disabled]="controlDisabled"
    [id]="'control' + layoutNode?._id"
    [name]="controlName"
    "): MaterialInputComponent@10:8
    Can't bind to 'name' since it isn't a known property of 'md-input'.
  5. If 'md-input' is an Angular component and it has 'name' input, then verify that it is part of this module.
  6. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [disabled]="controlDisabled"
    [id]="'control' + layoutNode?._id"
    [ERROR ->][name]="controlName"
    [placeholder]="options?.title"
    [readonly]="options?.readonly ? '"): MaterialInputComponent@12:8
    Can't bind to 'placeholder' since it isn't a known property of 'md-input'.
  7. If 'md-input' is an Angular component and it has 'placeholder' input, then verify that it is part of this module.
  8. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [id]="'control' + layoutNode?._id"
    [name]="controlName"
    [ERROR ->][placeholder]="options?.title"
    [readonly]="options?.readonly ? 'readonly' : null"
    [st"): MaterialInputComponent@13:8
    Can't bind to 'readOnly' since it isn't a known property of 'md-input'.
  9. If 'md-input' is an Angular component and it has 'readOnly' input, then verify that it is part of this module.
  10. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [name]="controlName"
    [placeholder]="options?.title"
    [ERROR ->][readonly]="options?.readonly ? 'readonly' : null"
    [style.width]="'100%'"
    [type]="lay"): MaterialInputComponent@14:8
    Can't bind to 'type' since it isn't a known property of 'md-input'.
  11. If 'md-input' is an Angular component and it has 'type' input, then verify that it is part of this module.
  12. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [readonly]="options?.readonly ? 'readonly' : null"
    [style.width]="'100%'"
    [ERROR ->][type]="layoutNode?.type"
    [value]="controlValue"
    (input)="updateValue($event)">
    "): MaterialInputComponent@16:8
    Can't bind to 'value' since it isn't a known property of 'md-input'.
  13. If 'md-input' is an Angular component and it has 'value' input, then verify that it is part of this module.
  14. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [style.width]="'100%'"
    [type]="layoutNode?.type"
    [ERROR ->][value]="controlValue"
    (input)="updateValue($event)">
    <span *ngIf="options?.fieldAddo"): MaterialInputComponent@17:8
    'md-input' is not a known element:
  15. If 'md-input' is an Angular component, then verify that it is part of this module.
  16. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
    [ERROR ->] ; Task: Promise.then ; Value: SyntaxError {__zone_symbol__error: Error: Template parse errors:

Can't bind to 'required' since it isn't a known property of 'md-input'…, _nativeError: ZoneAwareError, __zone_symbol__stack: "Error: Template parse errors:↵Can't bind to 'requi…http://localhost:4201/vendor.bundle.js:258970:35)", __zone_symbol__message: "Template parse errors:↵Can't bind to 'required' si…id + 'Status'"↵ "): MaterialInputComponent@2:6"} Error: Template parse errors:
Can't bind to 'required' since it isn't a known property of 'md-input'.

  1. If 'md-input' is an Angular component and it has 'required' input, then verify that it is part of this module.
  2. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [attr.minlength]="options?.minLength"
    [attr.pattern]="options?.pattern"
    [ERROR ->][required]="options?.required"
    [class]="options?.fieldHtmlClass"
    [disabled]="controlD"): MaterialInputComponent@8:8
    Can't bind to 'disabled' since it isn't a known property of 'md-input'.
  3. If 'md-input' is an Angular component and it has 'disabled' input, then verify that it is part of this module.
  4. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [required]="options?.required"
    [class]="options?.fieldHtmlClass"
    [ERROR ->][disabled]="controlDisabled"
    [id]="'control' + layoutNode?._id"
    [name]="controlName"
    "): MaterialInputComponent@10:8
    Can't bind to 'name' since it isn't a known property of 'md-input'.
  5. If 'md-input' is an Angular component and it has 'name' input, then verify that it is part of this module.
  6. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [disabled]="controlDisabled"
    [id]="'control' + layoutNode?._id"
    [ERROR ->][name]="controlName"
    [placeholder]="options?.title"
    [readonly]="options?.readonly ? '"): MaterialInputComponent@12:8
    Can't bind to 'placeholder' since it isn't a known property of 'md-input'.
  7. If 'md-input' is an Angular component and it has 'placeholder' input, then verify that it is part of this module.
  8. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [id]="'control' + layoutNode?._id"
    [name]="controlName"
    [ERROR ->][placeholder]="options?.title"
    [readonly]="options?.readonly ? 'readonly' : null"
    [st"): MaterialInputComponent@13:8
    Can't bind to 'readOnly' since it isn't a known property of 'md-input'.
  9. If 'md-input' is an Angular component and it has 'readOnly' input, then verify that it is part of this module.
  10. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [name]="controlName"
    [placeholder]="options?.title"
    [ERROR ->][readonly]="options?.readonly ? 'readonly' : null"
    [style.width]="'100%'"
    [type]="lay"): MaterialInputComponent@14:8
    Can't bind to 'type' since it isn't a known property of 'md-input'.
  11. If 'md-input' is an Angular component and it has 'type' input, then verify that it is part of this module.
  12. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [readonly]="options?.readonly ? 'readonly' : null"
    [style.width]="'100%'"
    [ERROR ->][type]="layoutNode?.type"
    [value]="controlValue"
    (input)="updateValue($event)">
    "): MaterialInputComponent@16:8
    Can't bind to 'value' since it isn't a known property of 'md-input'.
  13. If 'md-input' is an Angular component and it has 'value' input, then verify that it is part of this module.
  14. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
    ("
    [style.width]="'100%'"
    [type]="layoutNode?.type"
    [ERROR ->][value]="controlValue"
    (input)="updateValue($event)">
    <span *ngIf="options?.fieldAddo"): MaterialInputComponent@17:8
    'md-input' is not a known element:
  15. If 'md-input' is an Angular component, then verify that it is part of this module.
  16. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
    [ERROR ->]

consoleError @ zone.js:516
_loop_1 @ zone.js:545
drainMicroTaskQueue @ zone.js:549
zone.js:518 "

Cannot set property 'isInputWidget' of undefined.

I'm having the following error when he's trying to create a form :
Cannot set property 'isInputWidget' of undefined at ViewWrappedE…, _nativeError: ZoneAwareError, originalError: TypeError: Cannot set property 'isInputWidget' of undefined at Bootstrap3Component.initializeCon…, context: DebugContext, __zone_symbol__currentTask: ZoneTask…}

My project that has this issue you can find at : https://github.com/Punkiebe/FootballWorld/

Bootstrap is working correctly in my home page, I use json-schema-form in my admin module.

Here a list of the modules I use :

+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

In my angular-cli config I added this for bootstrap :

"styles": [ "../node_modules/bootstrap/dist/css/bootstrap.css", "styles.css" ], "scripts": ["../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap/dist/js/bootstrap.js"],

Someone an idea what I did wrong to activate the bootstrap framework?
In the readme there's not a lot on how to change frameworks.

Also when I remove [framework]="selectedFramework" I still get the same error.

Render schema form horizontally

Hi, is there anyway I could render a HTML form horizontally like
[LABEL] ==== [INPUT]
In an inline format?

I have tried putting on bootstrap classes but nothing seems to work. Any idea?

Error when calling initializeControl from custom widget.

When I call the method initializeControl on an instance of JsonSchemaFormService from within a custom widget component I get the following error:

"Error in :0:0 caused by: Cannot read property 'hasOwnProperty' of null"

I wonder if this has something to do with the injection of JsonSchemaFormService (I provide it inside my module because otherwise the service is unknown) or if this is otherwise broken.

The custom component is a copy of everything defined in InputComponent for testing so nothing custom is taking place at this point.

ERROR in Error encountered resolving symbol values statically - Angular CLI

I just tried the library on an angular cli setup, and the moment I add angular2-json-schema-form into my app module or any other module, I am getting the above error. The log is as below:

The issue is coming the moment I am adding JsonSchemaFormModule.forRoot(), in the import array of my module.

ERROR in Error encountered resolving symbol values statically. Calling function 'JsonSchemaFormModule', function calls are not supported. Consider
replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/Projects/sample-portal-old/src/app/app.module.ts, resolving symbol AppModule in C:/Projects/sample-portal-old/src/app/app.module.ts

My Setup:
angular-cli: 1.0.0-beta.24
node: 7.2.1
os: win32 x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
@angular/compiler-cli: 2.4.1

I did some research of my own about this issue and a lot of libraries are giving this issue.
Reference:
angular/angular-cli#3674 (comment)
angular/angular-cli#3707
auth0/angular2-jwt#258

Most of the comments made me conclude that metadata need to be published with the library as well.

Since I am new to angular so could not look more deeper into this issue. Can you have a look onto this.

Angular 4 RC version Support

@dschnelldavis I am trying to implement this library on angular 4, its working fine. But due to its dependencies on angular 2 and material 2, I am having issues while creating a shrink wrap.

What do you suggest.

Cannot import WidgetLibraryService

Version: v0.4.0-alpha.7

import { WidgetLibraryService } from 'angular2-json-schema-form';

The error message is has no exported member 'WidgetLibraryService'.

If I use...

import { WidgetLibraryService } from 'angular2-json-schema-form/src/widget-library/widget-library.service';

It can build success, but will get the same error if I use WidgetLibraryService in constructor

constructor(private widgetLibrary: WidgetLibraryService) {}

My project is create by ng create with angular-cli 1.1.0

{
  "name": "angular4",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.1.0",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "2.5.45",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

creating custom widget

Can you post any examples related to Add new 'custom-control' widget in angular2-json-schema

Update operation: populate values

I have an use case where I'm using angular2-json-schema-form to perform CRUD operation. I am using the schema to polpulate the form controls and then storing the values as a key-value pair(JSON) in the database.
How do I pre-populate the values to the controls?
How to use [model] attribute with

Kudos for awesome library!!

Thanks

Not work with angular-cli

It always fails with Error: moduleId should be a string in "TabsComponent". I can make it work after removing moduleId from dist/widgets/. But fail to start the playground after removing moduleId from source.

Unable to use 'condition'

I am using angular2-json-schema-form and trying to make use of the ‘condition’ functionality. In the playground examples for ASF there is the ‘Hack: Conditional Required’ example:

{
  "schema": {
    "type": "object",
    "properties": {
      "switch": {
        "title": "Spam me, please",
        "type": "boolean"
      },
      "email": {
        "title": "Email",
        "type": "string",
        "pattern": "^\\S+@\\S+$",
        "description": "Email will be used for evil."
      }
    },
    "required": [
      "switch"
    ]
  },
  "form": [
    {
      "type": "help",
      "helpvalue": "<p>Schema Form does not support oneOf (yet), but you can do a workaround and simulate certain scenarios with 'condition' and 'required'  (and/or 'readonly') in the form.</p>"
    },
    "switch",
    {
      "key": "email",
      "condition": "model.switch",
      "required": true
    },
    {
      "key": "email",
      "condition": "!model.switch"
    },
    {
      "type": "submit",
      "style": "btn-info",
      "title": "OK"
    }
  ]
}

I have found that both fields are displayed, and the value of ‘condition’ appears to have no effect?

screenshot

onClick event in actions don't seem to work

I couldn't find an example in your library where the onClick event for custom buttons seem to work.
Example:
{
"type": "actions",
"items": [
{
"type": "submit",
"style": "btn-info",
"title": "Do It!"
},
{
"type": "button",
"style": "btn-danger",
"title": "Noooooooooooo",
"onClick": "sayNo()"
}
]
}

Will update for Angular4??

This angular2-json-schema-form using in Angular4 doesn't be build .
This will be updated for Angular4?

Q: Why [data] isn't 2-way binding

i have in code

<json-schema-form
						[schema]="jsonSchema"
						[form] = "jsonForm"
						[data]="jsonData"

why this.jsonData wont change when i change form input data ?

update
i manualy patch value but in form view there is not ant change until i click on any other field..
this.jsfComponent.jsfObject.formGroup.patchValue({first_name: 'nowak kurwa'});

update2
//changeDetection: ChangeDetectionStrategy.OnPush, helps how to overide or solve problem with update data model from parent component ??

Form builder

It would have been great if have form builder to generate complex and conditional form as json schema.
So this schema render would have been more help.

Is angular2-json-schema-form AOT compatible?

Getting error while implementing i18n and it seems libraries used in the application are not AOT compatible. Please let me know whether angular2-json-schema-form is AOT compatible?

Template parse errors when I use the json-schema-form in feature modules

I imported the 'JsonSchemaFormModule ' in app.module and I used the

`<json-schema-form
  [schema]="yourJsonSchema"
  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form>`

in feature module components.

I got the following error,

errors.ts:42 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'schema' since it isn't a known property of 'json-schema-form'.
1. If 'json-schema-form' is an Angular component and it has 'schema' input, then verify that it is part of this module.
2. If 'json-schema-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<!--<dynamic-form [schemas]="schema"></dynamic-form>-->

<json-schema-form [ERROR ->][schema]="yourJsonSchema"
                  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form"): ng:///app/dashboard/dashboard.component.html@3:18
'json-schema-form' is not a known element:
1. If 'json-schema-form' is an Angular component, then verify that it is part of this module.
2. If 'json-schema-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<!--<dynamic-form [schemas]="schema"></dynamic-form>-->

[ERROR ->]<json-schema-form [schema]="yourJsonSchema"
                  (onSubmit)="yourOnSubmitFn($event)">
"): ng:///app/dashboard/dashboard.component.html@3:0
Error: Template parse errors:
Can't bind to 'schema' since it isn't a known property of 'json-schema-form'.
1. If 'json-schema-form' is an Angular component and it has 'schema' input, then verify that it is part of this module.
2. If 'json-schema-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<!--<dynamic-form [schemas]="schema"></dynamic-form>-->

<json-schema-form [ERROR ->][schema]="yourJsonSchema"
                  (onSubmit)="yourOnSubmitFn($event)">
</json-schema-form"): ng:///app/dashboard/dashboard.component.html@3:18
'json-schema-form' is not a known element:
1. If 'json-schema-form' is an Angular component, then verify that it is part of this module.
2. If 'json-schema-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<!--<dynamic-form [schemas]="schema"></dynamic-form>-->

[ERROR ->]<json-schema-form [schema]="yourJsonSchema"
                  (onSubmit)="yourOnSubmitFn($event)">
"): ng:///app/dashboard/dashboard.component.html@3:0
    at syntaxError (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:1513:34)
    at TemplateParser.parse (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:11951:19)
    at JitCompiler._compileTemplate (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25723:39)
    at eval (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25647:62)
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25647:19)
    at createResult (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25532:19)
    at ZoneDelegate.invoke (http://localhost:55177/node_modules/zone.js/dist/zone.js:391:26)
    at Object.onInvoke (http://localhost:55177/node_modules/@angular/core/bundles/core.umd.js:4132:37)
    at ZoneDelegate.invoke (http://localhost:55177/node_modules/zone.js/dist/zone.js:390:32)
    at syntaxError (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:1513:34)
    at TemplateParser.parse (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:11951:19)
    at JitCompiler._compileTemplate (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25723:39)
    at eval (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25647:62)
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25647:19)
    at createResult (http://localhost:55177/node_modules/@angular/compiler/bundles/compiler.umd.js:25532:19)
    at ZoneDelegate.invoke (http://localhost:55177/node_modules/zone.js/dist/zone.js:391:26)
    at Object.onInvoke (http://localhost:55177/node_modules/@angular/core/bundles/core.umd.js:4132:37)
    at ZoneDelegate.invoke (http://localhost:55177/node_modules/zone.js/dist/zone.js:390:32)
    at resolvePromise (http://localhost:55177/node_modules/zone.js/dist/zone.js:769:31)
    at resolvePromise (http://localhost:55177/node_modules/zone.js/dist/zone.js:740:17)
    at http://localhost:55177/node_modules/zone.js/dist/zone.js:817:17
    at ZoneDelegate.invokeTask (http://localhost:55177/node_modules/zone.js/dist/zone.js:424:31)
    at Object.onInvokeTask (http://localhost:55177/node_modules/@angular/core/bundles/core.umd.js:4123:37)
    at ZoneDelegate.invokeTask (http://localhost:55177/node_modules/zone.js/dist/zone.js:423:36)
    at Zone.runTask (http://localhost:55177/node_modules/zone.js/dist/zone.js:191:47)
    at drainMicroTaskQueue (http://localhost:55177/node_modules/zone.js/dist/zone.js:584:35)
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:55177/node_modules/zone.js/dist/zone.js:490:25)

NPM Module behaves different than lib version. Problems with Material Design and selected framework.

Hello!
If I use the npm installation as described in the documentation, the generated forms are not render correctly. I use material design and am not sure if it is because of the selected framework or if I missed something but the npm package also does not give access to a FrameworkLibraryService.

import {FrameworkLibraryService} from 'angular2-json-schema-form/src/framework-library';
leads to: Can't resolve 'angular2-json-schema-form/src/framework-library'...

the path referenced in the documentation is:
import { FrameworkLibraryService } from 'angular2-json-schema-form';
but angular2-json-schema-form has no exported member 'FrameworkLibraryService'

also [framework]='material-design' or [framework]='boostrap-3' does not have any effect on the rendering.

I tried out the lib version provided in the example app. There the rending works, but would definitely not be the preferred way of using the package.

rsync npm step raisning error while installing

Hi,

I tried exploring your library because I am also interested in something similar to what you are trying to do but was unable to explore it properly as the example project is not get installed properly on windows platform. It throws error at rsync step.

Can you put some documentation around that step so that I have a better understanding how rsync works as I do not have enough experience with rsync.

Is there any work around for rsync step.

I am also interested in contributing to this project as it seems very interesting and a good learning to step up in angular2 learning.

Looking forward to hear from you.

[email protected]

Dynamic update of the schema loses focus

Hi Davis,

I am trying to update my schema dynamically based on the input, which were made by the user.
For an example, please see http://brutusin.org/json-forms/
But still I have a problem: I always loose the focus while typing.

Is there a possibility to check to add the ViewFocus into the event of onChange(event)?
Or do you have any other Ideas?

Best regards,

Justin

It has any data to [data] when array is null

I want to send a data vis [data] but my data has a null array .
When I send this data ,it pop a error which is there have a null .

Any solution can solve it whitout remove the array or give the array "" string

Form onSubmit - model not updated

Hi :)

I want to use the generated form to update my model (and database) but when I catch the "submit" click and printing the model, I see the original data and not the updated data. Looks like the model is not 2-way-bound to the form.

What is the right way to implement updating of data via the angular2-json-schema-form library?

My template:

		[schema]="mySchema"
		[model]="preferencesModel"
		loadExternalAssets="true"
		(onSubmit)="onSubmitPreferences($event)">
</json-schema-form>

My component:


@Component({
	selector: 'app-preferences-form',
	templateUrl: './preferences-form.component.html',
	styleUrls: ['./preferences-form.component.css']
})

export class PreferencesFormComponent implements OnInit {
	@Input() preferences; // This is an Observable on the data.
	preferencesModel; // This is the actual data model

	mySchema = {
		"type": "object",
		"properties": {
			"employment_status": {
				"type": "string",
				"maxLength": 10,
				"enum": ["Employed", "Unemployed"]
			},
			"status_current": {
				"type": "string",
				"maxLength": 100,
				"enum": ["Actively Looking", "Open to offers"]
			},
			"employment_type": {
				"type": "string",
				"maxLength": 50,
				"enum": ["Full time", "Part time"]
			},
			"desired_salary": {
				"type": "integer",
			},
			"desired_salary_period": {
				"type": "string",
				"minLength": 1,
				"maxLength": 1
			},
			"benefits": {
				"type": "boolean"
			},
			"start_immediately": {
				"type": "boolean"
			},
			"start_time": {
				"type": "string",
				"format": "date-time"
			},
			"legal_usa": {
				"type": "boolean"
			},
			"only_current_location": {
				"type": "boolean"
			},
			"relocation": {
				"type": "boolean"
			},
			"locations": {
				"type": "array",
				"items": {
					"$ref": "#/definitions/Location"
				}
			}
		},
		"definitions" : {
			"Location" : {
				"type" : "object",
				"properties" : {
					"continent_id" : {
						"type" : "integer",
					},
					"continent_name" : {
						"type" : "string"
					},
					"city_id" : {
						"type" : "integer",
					},
					"city_name" : {
						"type" : "string"
					},
					"state_id" : {
						"type" : "integer",
					},
					"state_name" : {
						"type" : "string"
					},
					"state_short_name" : {
						"type" : "string"
					},
					"country_id" : {
						"type" : "integer",
					},
					"country_name" : {
						"type" : "string"
					},
					"country_short_name_alpha_3" : {
						"type" : "string",
						"maxLength" : 3
					},
					"country_short_name_alpha_2" : {
						"type" : "string",
						"maxLength" : 2
					}
				}
			}
		}
	};

	constructor() {
	}

	ngOnInit() {
		this.preferences.subscribe(response => {
			this.preferencesModel = response;
		});
	}

	onSubmitPreferences(event) {
		console.log(this.preferencesModel);
	}
}

How to create server validation?

Hi. Your package is realy nice! 😀 It is very helpful! However I have question.. how to add server validation? I created django package which create json from django forms. This package work with django rest framework.. but i don't have idea how to use specific validations for field.

Nested array errors

I am trying to generate a structure similar to the following:

[
    {
       "field":"..",
       "array_field": [
          {
               "another_field": "..",
               "array_field": [
                   {},{}, ...
               ]
          }
       ]
    },
    {}
]

Basically I am trying to create a nested structure of arrays and objects. I have attached my schema. The library loads the components correctly, but inputting data into the deeply nested fields throw a bunch of errors. Here is the error message:

formissue

Here is the schema:


{
  "schema": {
    "properties": {
      "tiers": {
        "type":"array",
        "items":{
           "$ref": "#/definitions/tiers_obj",
           "extendRefs":true
        }
      }
    },
    "definitions": {
      "tiers_obj":{
        "type":"object",
        "properties":{
            "min_amount":{
                "type":"integer",
                "title":"min amount"
            },
            "max_amount":{
                "type":"integer",
                "title":"max amount"
            },
            "Fees":{
                "title":"fees",
                "type":"array",
                "items":{
                    "$ref":"#/definitions/fees_obj"
                }
            }
        }
      },
      "fees_obj":{
        "type":"object",
        "title":"Fees_obj",
        "properties":{
            "ongoing_fee":{
                "type":"integer",
                "title":"ong"
            },
            "application_fee":{
                "type":"integer",
                "title":"app"
            }
        }
      }
    }
  }
}

Doesnt build in production mode at angular2-webpack.

Error message:
"Error encountered resolving symbol values statically. Calling function 'JsonSchemaFormModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/Users/mmv/angular2-webpack-starter-master/src/app/app.module.ts, resolving symbol AppModule in C:/Users/mmv/angular2-webpack-starter-master/src/app/app.module.ts"

I had tried include like, as in the documentation:

@NgModule({
declarations: [ AppComponent ],
imports: [
BrowserModule, FormsModule, HttpModule,
MaterialModule.forRoot(), JsonSchemaFormModule.forRoot()
],
providers: [],
bootstrap: [ AppComponent ]
})

Append json value into the element HTML

"lname": {
"title": "Last Name {{lname.code}}",
"type": "string",
"maxLength": 20,
"code":2000
}

I want the title of this field to be Last Name superscripted by the code value i.e. 2000. Can I do this? If yes, please explain how?

Do you have any example for the lazyload?

in my case, some of my page are using the lazy-load, but when i imported the JsonSchemaFormModule into my module, i will meet the error message about the BrowserModule is already loaded, i am ensure that other modules are in the same way, but the browsermodule Error is not appeared.
so do you having any solutions in my case?

ps: i had import the BrowserModule in the app.module.ts and import the CommonModule in other sub modules

thanks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.