whyAto8 whyAto8 - 1 year ago 74
Javascript Question

Ember - controller not overriding inherited property

I have 2 controllers, one extending the other. I have a property called "order" defined in one of them. I need to change its value in the other controller, which extends the first one. But its not doing so.

Controller A:

define('ControllerA', function(){
var controller = Ember.Controller.extend({
order:1
})
return controller;
})


Controller B:

define('ControllerB', ['ControllerA'], function(ControllerA){
var controller = ControllerA.extend({
order:2
})
return controller;
})


This is a very minified version of both controllers. They each have different routes, which essentially show the same components, but with different data, which changes based on the
order
property.

When I go to the 2nd route, i.e. B, the value of
order
is not being overridden (I want it to be
2
, but it still picks it up as
1
).

Am I missing something?

Answer Source

I realized, it was the problem in the parent controller it was inheriting from, this property was being overridden there only on model change. So, that was causing the issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download