WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

EmberJS Displaying Keys in an Object


You can show the keys in the article by utilizing the #each-in partner and it repeats once for each key go in object.

Syntax

 

<ul> 

{{#each-in array_name as |block-param| }} 

<li>{{block-param}}</li> 

{{/each}} 

</ul> 

In the above code, format repeats array_name, which incorporates objects and each key in the article determined as block-param.

Example

The precedent given beneath showcases the keys in the item by utilizing the #each-in aide. To show the things, make a part by utilizing the accompanying order −

 

ash g segment store-classifications 

Now open the store-categories.js made under app/part/ alongside the accompanying code −

 

import Ember from 'ash'; 

send out default Ember.Component.extend ({ 

willRender() { 

this.set('typesOfvehicles', { 

'Vehicles': ['Ferrari', 'Audi', 'BMW'], 

'Engine bicycles': ['Harley-Davidson', 'Yamaha','Honda'] 

}); 

} 

}); 

Create a layout called store-categories.hbs under app/formats/ with the accompanying code −

 

<ul> 

{{#each-in typesOfvehicles as |category products|}} 

<li>{{category}} 

<ol> 

{{#each items as |product|}} 

<li>{{product}}</li> 

{{/each}} 

</ol> 

</li> 

{{/each-in}} 

</ul> 

To list the keys in the item, utilize the accompanying code in the application.hbs record made under app/formats/

 

<p>This is Displaying the Keys in an Object:</p> 

{{store-categories}} 

{{outlet}}