Search code examples
ember.jshandlebars.jshtmlbars

Access a hash with a dynamic variable - getting Parse error Expecting 'ID', got 'INVALID'


I have a hash in my route defined as:

model: function() {
  return Ember.RSVP.hash({
    signedServices: {
      lyft: false,
      uber: false,
      postmates: false,
      doordash: false,
      caviar: false
    }
  });
},

In my handlebar view, I'm iterating through all my services and outputting the value of the hash:

{{#each (signup-services-array model.signedServices) as |serviceName|}}
  {{model.signedServices[serviceName]}}
{{/each}}

However, I keep running into the error:

Parse error on line 108:
...        {{log model.signedServices['lyft
-----------------------^
Expecting 'ID', got 'INVALID'

What does this error mean and how do I resolve it?


Solution

  • You can't access keys in objects in HTMLBars this way. You should use get helper instead:

    {{get model.signedServices serviceName}}