如何使用 Angular Schema Form Checkbox 布尔值处理 onChange?
How to handle onChange with Angular Schema Form Checkbox boolean?
我似乎无法触发此 onChange 事件。我已按照文档将方法添加到代码中,但没有任何反应。
$scope.schema = {
"type": "object",
"title": "Comment",
"properties": {
"comment": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "boolean",
"title": "Name"
},
"eligible": {
"type": "boolean",
"title": "Eligible for awesome things"
},
"code": {
"type":"boolean",
"title": "The Code"
}
}
}
},
"comment2": {
"type": "boolean",
"title": "Name"
}
},
"required": [
"comment"
]
};
$scope.form = [
{
key: "comment",
onChange: function(model, form){
console.log('got there though');
}
},
{
type: "boolean",
onChange: function(model, form){
console.log('this');
}
},
{
type: "submit",
title: "Save"
}
];
$scope.model = {};
看看这个 plunker:http://plnkr.co/edit/XJGuPYPBDc7520vjWtbI?p=preview
星期五想出了这个。我需要在表单定义中按键引用每个 属性 。
引用更新的插件:http://plnkr.co/edit/XJGuPYPBDc7520vjWtbI?p=preview
$scope.form = [
{
key: 'comment',
add: null,
remove: null,
title: false,
notitle: true,
items:
[
{
key: "comment.name",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there ' + model.toString());
}
},
{
key: "comment.elgible",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there though');
}
},
{
key: "comment.code",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there though');
}
},
]
},
{
type: "submit",
title: "Save"
}
];
我似乎无法触发此 onChange 事件。我已按照文档将方法添加到代码中,但没有任何反应。
$scope.schema = {
"type": "object",
"title": "Comment",
"properties": {
"comment": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "boolean",
"title": "Name"
},
"eligible": {
"type": "boolean",
"title": "Eligible for awesome things"
},
"code": {
"type":"boolean",
"title": "The Code"
}
}
}
},
"comment2": {
"type": "boolean",
"title": "Name"
}
},
"required": [
"comment"
]
};
$scope.form = [
{
key: "comment",
onChange: function(model, form){
console.log('got there though');
}
},
{
type: "boolean",
onChange: function(model, form){
console.log('this');
}
},
{
type: "submit",
title: "Save"
}
];
$scope.model = {};
看看这个 plunker:http://plnkr.co/edit/XJGuPYPBDc7520vjWtbI?p=preview
星期五想出了这个。我需要在表单定义中按键引用每个 属性 。
引用更新的插件:http://plnkr.co/edit/XJGuPYPBDc7520vjWtbI?p=preview
$scope.form = [
{
key: 'comment',
add: null,
remove: null,
title: false,
notitle: true,
items:
[
{
key: "comment.name",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there ' + model.toString());
}
},
{
key: "comment.elgible",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there though');
}
},
{
key: "comment.code",
title: 'This',
type: 'boolean',
onChange: function(model, form){
alert('got there though');
}
},
]
},
{
type: "submit",
title: "Save"
}
];