Skip to content

Commit

Permalink
Merge pull request #19871 from jamescdavis/document_get_helper_array_…
Browse files Browse the repository at this point in the history
…element_access_with_number
  • Loading branch information
rwjblue authored Jan 12, 2022
2 parents 3c649ef + d59d321 commit 479e6e1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/@ember/-internals/glimmer/lib/helpers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
*/

/**
Dynamically look up a property on an object. The second argument to `{{get}}`
should have a string value, although it can be bound.
Dynamically look up a property on an object or an element in an array.
The second argument to `{{get}}` should have a string or number value,
although it can be bound.
For example, these two usages are equivalent:
Expand Down Expand Up @@ -77,6 +78,19 @@
Would allow the user to swap what fact is being displayed, and also edit
that fact via a two-way mutable binding.
The `{{get}}` helper can also be used for array element access via index.
This would display the value of the first element in the array `this.names`:
```handlebars
{{get this.names 0}}
```
Array element access also works with a dynamic second argument:
```handlebars
{{get this.names @index}}
```
@public
@method get
@for Ember.Templates.helpers
Expand Down

0 comments on commit 479e6e1

Please sign in to comment.