문제

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!

도움이 되었습니까?

해결책

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);
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top