Angular架构表单默认不亮

时间:2015-06-04 09:07:15

标签: angular-schema-form

我们使用angular-schema-from来表示来自json schema的redring表单和来自

的json

我们如何获取枚举的默认值

请参阅以下表格和架构......

架构json:

{
    "type": "object",
    "title": "Comment",
    "properties": {
        "contactDetails": {
            "title": "Contact Person",
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "properties": {
                    "contactType": {
                        "title": "Contact Type",
                        "description": "Select",
                        "type": "string",
                        "default": "test",
                        "enum": ["test", "test1"]
                    }
                }
            }
        }
    }
}

表格json:

[
    "contactDetails[].contactType",
    {
        "type": "submit",
        "style": "btn-info",
        "title": "OK"
    }
]

1 个答案:

答案 0 :(得分:2)

由于数组与您的表单定义相结合,您无法访问数组中的字段而不将其包装在数组类型中。

请尝试使用此表单定义:

[
    {
        "type": "array",
        "key": "contactDetails",
        "items": [
            "contactDetails[].contactType"
        ]
    },
    {
        "type": "submit",
        "style": "btn-info",
        "title": "OK"
    }
]

示例:http://schemaform.io/examples/bootstrap-example.html#/c0cf38b387b84e567176