Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Ember.js Controllers Routes and Templates

Andre Kovac
Andre Kovac
5,588 Points

Does Ember always require an anonymous function for a action property?

In the following Controller definition the alert function is wrapped into a anonymous function definition.

Blogger.AboutController = Ember.Controller.extend({
  actions: {
    showRealName: function() {
      alert("Dracula's real name is....");
    }
  }
});

Why does the following (i.e. not wrapping the alert) not work and give me the Ember Error, that I haven't implemented the action for showRealName?

Blogger.AboutController = Ember.Controller.extend({
  actions: {
    showRealName: alert("Dracula's real name is....")
  }
});

showRealName has to be implemented with a function. And alert is a function. So why does it not work?

1 Answer

Had the same Problem, after several attempts, it worked, had to reload local server :-(