Question

I have two controllers: controller A and controller B. Controller A has a property called "total_price" which has a numeric value. I'd like to set the "total_price" value of Controller A to 0, from within controller B.

I know needs (http://emberjs.com/guides/controllers/dependencies-between-controllers/) lets you access other controller properties but I can't see anything in the documentation about setting another controller's properties.

How can I accomplish this? Thanks!

Était-ce utile?

La solution

If you use the needs api to get controller A, you can set values on that controller like you normally would.

NerfController = Ember.Controller.extend({
    needs: ['other'],

    setValueInOther: function(newValue) {
        this.get('controllers.other').set('value', newValue);
    }
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top