/ /角度スキーマフォーム - ボタンのパラメータとしてのarrayIndex onClick - javascript、angularjs、angular-schema-form

Angular Schema Form - ボタンのパラメータとしてarrayIndex - javascript、angularjs、angular-schema-form

どのようにしてarrayIndexをonClickの関数にパラメータとして渡すことができますか?例えば:

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

「条件」内のarrayIndexが機能します。 しかし、関数では、未定義は私が得ているものです。 someFunction(つまりsomeKeyにアクセスできます)のモデル全体またはフォームのデータにアクセスできますが、配列内の特定の項目(someKey [index]など)にアクセスする必要があります。

要求通りに更新されました: (スキーマフォームのサンプルページから取得)

performActionボタンを参照してください。私は、ボタンのコンテキスト内の電子メールを関数に渡す必要があります。

形:

[

{
"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.