简体   繁体   English

无法使用角度模式表单指令呈现复选框

[英]Not able to render checkbox using angular schema form directive

I am using angular schema form directive to render the form. 我正在使用角度模式表单指令来呈现表单。 I am able to render all the elements except checkbox. 我能够呈现除复选框以外的所有元素。 When I use checkbox I get following error: 当我使用复选框时,出现以下错误:

TypeError: Cannot read property 'default' of undefined TypeError:无法读取未定义的属性“默认”

JS: JS:

var ngSchemaForm = {};
     ngSchemaForm.schema={
         type: "object",
            properties: {
              cbProp: {
                    cb: { title: "I am checkbox", type: "boolean", default: false }
                },
            }
        }

        ngSchemaForm.cbSection={
         type: "conditional",
            condition: "model.currentSection=='cbSection'",
            items: [
                {
                    type: "section",
                    htmlClass: "row",
                    items: [
                        {
                            type: "section",
                            htmlClass: "col-lg-12",
                            items: [{ key: "cbProp.cb", type: "checkbox" }]
                        }
                    ]
                }
          ]
        }

        ngSchemaForm.form={
         "type": "section",
          "htmlClass": "container",
          "items": [ ngSchemaForm.cbSection ]
        }

        var formApp = angular.module('formApp', ['schemaForm']);

        formApp.controller('FormController', function ($scope) {
            $scope.schema = ngSchemaForm.schema;
            $scope.form = ngSchemaForm.form;
            $scope.model = { currentSection: "cbSection" };
        });

HTML: HTML:

<div id="formApp" ng-app="formApp" ng-controller="FormController">
    <p></p>
    <ng-form name="formApp" >
             <div sf-schema="schema"
                  sf-form="form"
                  sf-model="model">

            </div>
    </ng-form> 
</div>

changed: 改变:

items: [{ key: "cbProp.cb", type: "checkbox" }]

To: 至:

items: [{ key: "cbProp.cb" }]

and worked 并工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM