Defining custom functions on Routes & Controllers


How can i define my own functions on Route & Controller objects? For instance, say we have the following route object:

App.IndexRoute = Ember.Route.extend({
    beforeModel: function() { },
    model: function() {
        return App.SomeModel.findAll(); // returns a promise
    setupController: function(controller, model) {
        if(model !== undefined) {
    myCustomFunction(data) {
        // do something with data

When i run my app i get an error saying ‘myCustomFunction’ is undefined. However, i can define my own functions on Controller objects and they work fine. what is the best/proper way to define such functions?


App.IndexRoute = Ember.Route.extend({
    myCustomFunction(data) {    // seems the new syntax in ECMAScript 6


Thanks @IronBlood works like a charm. I had a typo though, i previously defined my function like the following:

myCustomFn: function() { }

This didn’t work, but after i changed the signature to MyCustomFn() { } it worked fined. weird, i tested both signatures and they seem to be working fine o_O something’s seriously messed up here.

anyway, works for now :slight_smile: thanks a lot