当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

angular-schema-form

Generate forms from a JSON schema, with AngularJS!
授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 陆仲渊
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Angular Schema Form

Generate forms from JSON schemas using AngularJS!

Why not many changes lately?

Much of the new development is being done in Assimilate, a standardised validator for JSON Schema to help ensure changing validators is never as painful as escaping tv4 is, as well as a new core library to allow for a more predictable upgrade from AngularJS to Angular.

The Blog / The Web Site / The Twitter / The Movie

medium.com/@SchemaFormIO / website / @SchemaFormIO / Movie

If you use ASF in your project/company please let us know! We'd love to feature you on the site.

There has been some recent developments in this project that you might want to read about.

Demo Time!

Try out the example page. Try editing the schema or form definition and see what comes out!

Hint: By pressing the 'Save to gist' button (top left), you can save your example into a shareable link.

Documentation

You can find all documentation here, it covers all the different field typesand their options.

It also covers how to extend angular schema form with your own field types.

Before filing an issue, please read our issue support instructions or you may be ignored.

What is it?

Schema Form is a set of AngularJS directives (and a couple of services). It can do two things tomake life easier:

  1. Create a form directly from a JSON schema.
  2. Validate form fields against that same JSON schema.

Schema Form uses convention over configuration, so it comes packaged with some sensible defaults.But you can always customize it by changing the order and types of form fields.

JSON Form

Schema Form is inspired by the nice JSON Form library andaims to be roughly compatible with it, especially its form definition. So what sets Schema Formapart from JSON Form?

  1. Schema Form integrates deeply with AngularJS and uses AngularJS conventions to handle forms.
  2. Schema Form uses tv4 for validation, making it compatiblewith version 4 of the JSON schema standard.
  3. By default, Schema Form generates Bootstrap 3-friendly HTML.

Migration Guide

If you already use the library factories in an app or an add-on or plan to upgrade versions, please read themigration guide for any items that may need consideration.

Basic Usage

First, expose your schema, form, and model to the $scope.

angular.module('myModule', ['schemaForm'])
       .controller('FormController', function($scope) {
  $scope.schema = {
    type: "object",
    properties: {
      name: { type: "string", minLength: 2, title: "Name", description: "Name or alias" },
      title: {
        type: "string",
        enum: ['dr','jr','sir','mrs','mr','NaN','dj']
      }
    }
  };

  $scope.form = [
    "*",
    {
      type: "submit",
      title: "Save"
    }
  ];

  $scope.model = {};
});

Then load them into Schema Form using the sfSchema, sfForm, and sfModel directives.

<div ng-controller="FormController">
    <form sf-schema="schema" sf-form="form" sf-model="model"></form>
</div>

Installation

NPM

npm i angular-schema-form@latest

For the latest pre-release (alpha)

npm i angular-schema-form@pre-release

Bower

It's simplest to install Schema Form using Bower.If you use the bootstrap decorator use the one from the angular-schema-form-bootstrap repo

bower install angular-schema-form angular-schema-form-bootstrap
bower install angular-schema-form angular-schema-form-bootstrap

This will install the latest release and basic dependencies. Seedependencies section below.

You can also load the files via cdnjs.com.

Manual

You can also just download the contents of the dist/ folder and add dependencies manually.

Dependencies

Schema form has a lot of dependencies, most of which are optional. Schema Form depends on:

  1. AngularJS version 1.3.x is recommended. Version 1.2.xhas some limitation. See known limitations.
  2. angular-sanitize
  3. tv4
  4. bootstrap 3

If you install via bower you get all of the above except bootstrap since wedon't want to push a certain version or flavor on you. Also makesure you got the angular version you actually want.

Additional dependencies

  1. If you'd like to use drag-and-drop reordering of arrays, you'll also need ui-sortable and its jQueryUI dependencies. See the ui-sortable documentation for details about which parts of jQueryUI are needed. You can safely ignore these if you don't need reordering.
  2. Schema Form provides tabbed arrays through the form type tabarray. Tab arrays default to tabs on the left side. For these to work, you'll need to include the CSS from bootstrap-vertical-tabs. However, you won't need Bootstrap Vertical Tabs for horizontal tabs (the tabType: "top" option).

The minified files include templates - no need to load additional HTML files.

Script Loading

Schema form is split into two main files, dist/schema-form.min.js anddist/bootstrap-decorator.min.js and they need be loaded in that order. AngularJS,tv4 and objectpathalso needs to be loaded before Schema Form.

<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="bower_components/angular-sanitize/angular-sanitize.min.js"></script>
<script type="text/javascript" src="bower_components/tv4/tv4.js"></script>
<script type="text/javascript" src="bower_components/objectpath/lib/ObjectPath.js"></script>
<script type="text/javascript" src="bower_components/angular-schema-form/dist/schema-form.min.js"></script>
<script type="text/javascript" src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script>

Module loading

Don't forget to load the schemaForm module or nothing will happen.

angular.module('myModule', ['schemaForm']);

Add-ons

There are several add-ons available, for a full list see the web page.Your can also create your own add-ons!

Contributing

Contributions are welcome! Please see Contributing.md for more info.

Building

The new Webpack compilation has made it easier to manage files and code and run buildscripts, but it is still not easy enough for users unfamiliar with it... yet.

NOTE in order to build simultaneously with json-schema-form-core you must have it clonedas a sibling directory to this one OR npm install the version you wish to build with.

Webpack now generates a header to indicate version and date of build. Do not create PR with the DIST folder.

Branch Status & New Add-On

This branch will be the next version of Angular Schema Form, currently please usethe examples/example.html file as the best example to get the framework working.

The example uses angular-schema-form.js and angular-schema-form-bootstrap.js for theversion of the code it executes, if you want your page to behave the same youobviously need the same version!

Add-on

To see how to make an add-on work I have now included the calculate add-on file within the examples/add-on directory.

Tests

Unit tests are run with karma and written usingmocha, chai andsinon

To run the tests:

  1. Install all dependencies via NPM.
  2. Install dev dependencies with bower.
  3. Install the Karma CLI.
  4. Run the tests using npm test.
$ npm install
$ bower install
$ npm test
  • 1、表单 this.form.patchValue(data) 单个赋值 this.form.patchValue({‘key’:value}) this.form.get('key').setValue('') 2、表格 this.items.at(i).patchValue({'字段值'})

  • Uncaught Error: Template parse errors: ‘XXX’ is not a known element: 问题 CUSTOM_ELEMENTS_SCHEMA 相关 Uncaught Error: Template parse errors: ‘XXX’ is not a known element: If ‘XXX’ is an Angular component,

  • NG-ZORRO 7.0.1 发布了,NG-ZORRO 是 Ant Design 的 Angular 实现,用于开发和服务于企业级后台产品。 此版本更新如下: Bug 修复 tree: 修复 setTimeOut 默认值的问题 (#3003) (050faa0), closes #3001 tree: 修复 tree-select 收起动画的问题 (#2997) (623a9ff) checkbo

  • 一、报错: error NG8002: Can't bind to 'isTemplate' since it isn't a known property of 'create-home'. 1. If 'create-home' is an Angular component and it has 'isTemplate' input, then verify that it is part

  • 一、 angular.json文件时如何产生的 angular6之前我们通过脚手架(angular cli)创建的项目会有一个angular-cli.json文件,此文件是cli的相关配置信息。 在angular6+的版本后,原先的angular-cli.json就被换成了angular.json。 而其中里面的字段变化挺大了,如果不了解基本的组成,或者直接把老版本的代码 copy 到新版本的工作

  • 1.创建文件、模块和组件 创建文件 ng new XXXXX 移动到该文件目录下 cd XXXXX npm install ng-zorro-antd --save(安装UI库) ng add ng-zorro-antd(把UI添加到项目) 2.主页面转移模块 原来html,less文件注掉,将新的html,less文件转移到welcome里 如果html报错就注册一下,其实看着报错的是哪个标签,

  • ngx-material相关网址 ​ 目前我们使用的是angular5,因此我们选择ngx-material v5版本。 官网地址 github地址 demo代码地址 引入material 引入material npm包以及相关的包 npm install @angular/material @angular/cdk 复制代码 因为一些Angular Material组件依赖Angular an

  • Angular_代码片段_一步步进行 <page-header title="簽核詳情"></page-header> <nz-card [nzBordered]="false" class="mb-lg" nzTitle="簽核进度"> <nz-steps [nzCurrent]=c.router_stage nzProgressDot> <nz-step [nzTitl

  • 在 Angular 4 中有多种方式可以更新表单的值,对于使用响应式表单的场景,我们可以通过框架内部提供的 API ,(如 patchValue 和 setValue )方便地更新表单的值。这篇文章我们将介绍如何使用 patchValue 和 setValue 方法更新表单的值,此外还会进一步介绍它们之间的差异。 Reactive Form Setup app.module.ts import {

 相关资料
  • // 创建指定数据表 Schema::create('table', function($table) { $table->increments('id'); }); // 指定一个连接 Schema::connection('foo')->create('table', function($table){}); // 通过给定的名称来重命名数据表 Schema::rename($from,

  • schema 是一个用于验证 Python 数据结构的库,例如从配置文件、表单、外部服务或命令行解析中获得的数据,从JSON/YAML(或其他东西)转换为 Python 数据类型。

  • 要使用本节中描述的AOP命名空间标记,您需要按照描述导入springAOP模式 - <?xml version = "1.0" encoding = "UTF-8"?> <beans xmlns = "http://www.springframework.org/schema/beans" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-insta

  • 主要内容:什么是 JSON Schema,定义 Schema,使用 JSON Schema 进行验证JSON Schema 是一个描述和验证 JSON 数据结构的强大工具,我们可以把 JSON Schema 看作是一种规范,这个规范中规定了 JSON 数据的结构、键的命名、值的类型等等,通过规范可以校验指定的 JSON 数据,保证数据的准确。所以在接口调试过程中,经常使用 JSON Schema 来校验接口数据的准确性。 什么是 JSON Schema JSON Schema 译为“JSON模式

  • Schema 是一个 Clojure(Script) 库,用来声明数据描述和验证。 代码示例: (ns schema-examples  (:require [schema.core :as s             :include-macros true ;; cljs only             ]))(def Data  "A schema for a nested data ty

  • Schema Registry Confluent Schema Registry provides a serving layer for your metadata. It provides a RESTful interface for storing and retrieving your Avro®, JSON Schema, and Protobuf schemas. It store