Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:28:31+00:00 2026-06-07T20:28:31+00:00

How to get index item of array in an emberjs view. This returns an

  • 0

How to get index item of array in an emberjs view.

This returns an error:

{{#view}}
  {{oneArray[0]}}
{{/view}}

I don’t want to use {{#each}} to show all items, just want to show the special index item. How?

Or can I get the index of {{#each}}?

{{#each oneArray}}
    {{#if index>0}}
         don't show the first item {{oneArray[index]}}
    {{/if}}
{{/each}} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:28:34+00:00Added an answer on June 7, 2026 at 8:28 pm

    As shown in this article, you can define a new array for including the index in each row:

    App.MyView = Ember.View.extend({
        oneArrayWithIndices: function() {
          return this.get('oneArray').map(function(item, index) {
            return {item: i, index: idx};
          });
        }.property('oneArray.@each')
    });
    

    and then in your template you can access the index like so:

    {{#each view.oneArrayWithIndices}}
      index: {{this.index}} <br />   
      item: {{this.item}}
    {{/#each}}
    

    However, since you just want to show specific items from the array, it is better to do it in your view (or even better in your controller). Try to keep your templates logic-less.

    Therefore, create a new array in your view/controller that includes only the items you want to show:

    myFilteredArray: function() {
      return this.get('oneArray').filter( function(item, index) {
        // return true if you want to include this item
        // for example, with the code below we include all but the first item
        if (index > 0) { 
          return true;     
        }    
      });
    }.property('oneArray.@each')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the array data like this: $tags = $_GET['item']['tags']; if ($tags){ foreach ($tags
How can I get the array index within a for (id item in items)
I want to get item 1, item 2 out of this simple HTML page:
I know that this works to get the first item of an array string
I want to get the index of a particular letter, e.g. > match(LETTERS,G) [1]
I want to get tab Index with it's id. My tabs are in a
I wanted to know how can we get the index of the array if
I have a listbox (detailed view). How do I get the index of the
I am trying to get the index of the current item within <ul id=navbar>
I have an array of objects, I find the item by index, assign a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.