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

 

 

Standard Options for form:

复制代码
{
  key: "address.street",      // The dot notatin to the attribute on the model
  type: "text",               // Type of field
  title: "Street",            // Title of field, taken from schema if available
  notitle: false,             // Set to true to hide title
  description: "Street name", // A description, taken from schema if available, can be HTML
  validationMessage: "Oh noes, please write a proper address",  // A custom validation error message
  onChange: "valueChanged(form.key,modelValue)", // onChange event handler, expression or function
  feedback: false,             // Inline feedback icons
  placeholder: "Input...",     // placeholder on inputs and textarea
  ngModelOptions: { ... },     // Passed along to ng-model-options
  readonly: true,              // Same effect as readOnly in schema. Put on a fieldset or array
                               // and their items will inherit it.
  htmlClass: "street foobar",  // CSS Class(es) to be added to the container div
  fieldHtmlClass: "street"     // CSS Class(es) to be added to field input (or similar)
}
复制代码

 

posted @   Zhentiw  阅读(1350)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示