Loading data from JS object using Ember HTMLbars template

82 Views Asked by At

I am a front end developer. In my webpage I was loading data from static JS object using Handlebars template. Now I planned to upgrade to Ember. I don't know where to keep my JS file and how to access JS object using HTMLbars template. Kindly help me on this.

2

There are 2 best solutions below

0
On

You can pass your javascript object to model in your route.

Ember.Route.extend({
  model: function(){
   return {
      name: 'prakash'
   } 
  }
}

Now in your htmlbars template access it as

{{model.name}}

Hope it helps.

0
On

You can still access data of static JavaScript object in HTMLBars. HTMLBars is evolution of Handlebars and it supports previous features.

I don't know where to keep my JS file and how to access JS object using HTMLbars template.

You should be able to do exactly the same thing now as you did before.