码迷,mamicode.com
首页 > Web开发 > 详细

[AngularJS] angular-schema-form -- 1

时间:2015-01-21 23:47:48      阅读:401      评论:0      收藏:0      [点我收藏+]

标签:

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"
  }

技术分享

 

[AngularJS] angular-schema-form -- 1

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/4240262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!