0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

{{#each}}のとき、child-componentにindexを渡したい

Last updated at Posted at 2015-03-25

EmberにおけるComponentは独立したものとして扱われるため、{{#each}}のときに自動でindexが与えられない。だから、明示的にindexを渡してやる必要がある。

{{#each item in list}}
  {{child-component
    index=_view.contentIndex
    }}
{{/each}}

なお、ember 0.11からブロックパラメータがサポートされるので下記のように書ける。

{{#each list as |item index|}}
  {{child-component
    index=index
    }}
{{/each}}
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?