Search code examples
ember.jsember-dataember-cli

ember functions - unexpected token


Am using ember version 2.5.1 I get the below syntax error:

SyntaxError: frontend/controllers/hmi/config/buckets-edit.js: Unexpected token (36:8)
  isFancy: false,
  firstName: {
    if (this.get('isFancy')) {
      return 'Hannah';
    } else {
      return 'nameless';

My code:

test.hbs;

      Hello my name is {{firstName}}
      <p>
          Check box if your name is Hannah: {{input type="checkbox" checked=isFancy}}
      </p>

controller/test.js;

  firstName: {
    if (this.get('isFancy')) {
      return 'Hannah';
    } else {
      return 'nameless';
    }.property('isFancy'),

  },

Solution

  • Your computed property should look like this.

    firstName: function(){
     if (this.get('isFancy')) {
       return 'Hannah';
    } else {
      return 'nameless';
    }.property('isFancy')