我正在使用角度模式表单指令来呈现表单。我能够渲染除复选框之外的所有元素。当我使用复选框时,出现以下错误:
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>