2016-08-05 1 views
2

Кажется, я не могу получить это событие onChange. Я добавил метод в код в соответствии с документацией, но ничего не происходит.Как обрабатывать onChange с угловой формой схемы Checkbox boolean?

$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

ответ

1

фигурного это один из пятницы. Мне нужно ссылаться на каждое свойство по ключу в определении формы.

Ссылка обновленный plunker: 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" 
} 
]; 
+0

Тайлер Джонс .... tjones ... вы ответили на свой вопрос под другой учетной записью? –

Смежные вопросы