简体   繁体   中英

How to get reference to the repeat parent index in aurelia?

i want to know if it's possible to pass a repeat parent index to a converter in a repeat?
I tried this :

<div repeat.for="row of router.navigation | myFilter:1:$parent.$index">

but it's not working !
Any idees ? Any workaround ?

It's possible- the code you have above should work. Here's a running example: https://gist.run?id=5df404d80be769a0d62aab2f7c9f300e

app.html

<template>
  <require from="./test-converter"></require>

  <div repeat.for="y of 3">
    <span repeat.for="x of 3">${ x * y | test : $index : $parent.$index }</span>
  </div>
</template>

app.js

export class App {
  message = 'Hello World!';
}

test-converter.js

export class TestValueConverter {
  toView(value, x, y) {
    return `(${x},${y},${value})`;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM