无法使用angular schema form指令呈现复选框

时间:2015-10-12 11:23:00

标签: javascript angularjs angular-schema-form

我正在使用angular schema form指令来呈现表单。我能够渲染除复选框之外的所有元素。当我使用复选框时,我收到以下错误:

  

TypeError:无法读取属性'默认'未定义的

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:

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

1 个答案:

答案 0 :(得分:0)

改变:

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

要:

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

并且工作