/ / Angular Schema Form - arrayIndex як параметр для кнопки onClick - javascript, angularjs, angular-schema-form

Angular Schema Form - arrayIndex як параметр для кнопки onClick - javascript, angularjs, angular-schema-form

Як я можу передати arrayIndex як параметр функції у onClick? Наприклад:

{
key:"someKey"
type:"array",
items:[
{
"key":"someKey[].itemNo"
},
{
"type":"button",
"onClick":"someFunction(someKey[arrayIndex].itemNo)"
}
]
}

arrayIndex у "умові" працює.Але у функції, undefined - це те, що я отримую. Я можу отримати доступ до всієї моделі або даних форми у someFunction (тобто я можу отримати доступ до someKey), але мені потрібен доступ до певного елементу в масиві (тобто someKey [індекс]).

ОНОВЛЕНО за запитом: (Взято зі сторінки прикладу форми схеми)

Дивіться кнопку виконувати дії. Мені потрібно, щоб електронна пошта в контексті кнопки була передана у функцію.

Форма:

[

{
"key": "comments",
"add": "New",
"style": {
"add": "btn-success"
},
"items": [
"comments[].name",
"comments[].email",
{
"key": "comments[].spam",
"type": "checkbox",
"title": "Yes I want spam.",
"condition": "model.comments[arrayIndex].email"
},
{
"key": "comments[].comment",
"type": "textarea"
},
{
"type":"button",
"onClick":"performAction(comments[arrayIndex].email)",
"title":"Perform Action"
}
]
},
{
"type": "submit",
"style": "btn-info",
"title": "OK"
}
]

Схема:

{
"type": "object",
"title": "Comment",
"required": [
"comments"
],
"properties": {
"comments": {
"type": "array",
"maxItems": 2,
"items": {
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"email": {
"title": "Email",
"type": "string",
"pattern": "^\S+@\S+$",
"description": "Email will be used for evil."
},
"spam": {
"title": "Spam",
"type": "boolean",
"default": true
},
"comment": {
"title": "Comment",
"type": "string",
"maxLength": 20,
"validationMessage": "Don"t be greedy!"
}
},
"required": [
"name",
"comment"
]
}
}
}
}

Відповіді:

1 для відповіді № 1

Це було додано в v1.0.0-alpha.1 з додаванням arrayIndices.