[AngularJS] angular-schema-form -- 1

Check out on gitHub, see the example on Demo page, see the document, extension.

 

Mainly, there are three parts consist of Javascript part:

form,  schema  and model.

 

Schema


 

I like define the schema first. Usually you will use two props:

typeproperties & required.

{
  "type": "object",
  "title": "Somehting ele",
  "properties": {
    "email": {
      "title": "Email",
      "type": "string",
      "pattern": "^\\S+@\\S+$",
      "description": "Email will be used for evil."
    }
  },
  "required": [
    "email"
  ]
}

 

In ‘properties‘, is the place where you define the form elements. For example - "email".

 

Form


 

Then in the form, if you thing the schema setting is ok, then in form:

[
   "email"   
]

技术分享

 

Also you can overwrite the form: for example,  I want to over the title, add a placeholder.

{
      "key": "email",
      "type": "string",
      "title": "Email filed",
      "placeholder": "Email"
  }

"key" in the example matchs to the "email" in the shcema.

 

A good example for input field:

Schema:

"email": {
      "title": "Email",
      "type": "string",
      "pattern": "^\\S+@\\S+$",
      "maxlength": 120,
      "minlength": 3,
"validationMessage": "This is not an email"
"description": "Email will be used for evil." }

Form:

  {
      "key": "email",
      "type": "string",
      "title": "Email filed",
      "placeholder": "Email"
  }

技术分享

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。