Reputation: 610
I have a controller with a few methods attached to it. I have a relevant route. I added the methods inside the controller so that they can be re-used in a few other places. These methods retrieve some data from the server. Inside the setupController of the route, I'm calling these methods and everything works as expected.
But once I concatenate the files, Ember throws an error saying the method I'm trying to call is undefined. I use grunt-contrib-concat plugin but also tried changing it to use uglify. Still the same issue. I don't think there is anything wrong with the concatenation as it always worked previously. However, I never used the setupController before other than to set properties. Added the sample code below. Any help is appreciated.
/* Ember 1.10.0 Debug version */
/* Route */
App.DashboardRoute = Ember.Route.extend({
model: function() { return []; },
setupController: function(controller, model) {
this._super(controller, model);
/* Setting values on the controller works */
controller.set('currentDate', new Date());
/* Calling a method works normally but throws error when minified */
/* Error: dashboard undefined is not a function */
controller.addNumbers();
}
});
/* Controller */
App.DashboardController = Ember.ArrayController.extend({
currentDate: null,
addNumbers: function() {
return 1 + 2;
}
});
Upvotes: 0
Views: 318
Reputation: 692
I would say you need to look at the minified code or the order that the code is being concatendated, but it's not a problem with setupController
.
I created a JSbin with your example and run it through Uglify, and it works correctly.
http://emberjs.jsbin.com/mizudelupi/2/
If you can create a JSbin with your minified, concatendated code, we can take a look and help.
Upvotes: 1