How to access view property from controller in emberjs

198 views Asked by At

I have a method in controller where I need to access a view property and set it value. How to achieve this in emberjs?

1

There are 1 answers

1
Griffosx On

If you want to rerender a view that depends on a controller's property, just bound it in your template

{{#view "myView" foo=controllerProperty}}
    {{propertyThatDependsOnFoo}}
{{/view}}


App.MyView = Ember.View.extend({
    foo: null, // initialized in template
    ...
    propertyThatDependsOnFoo: function() {
        ...
    }.property("foo")
});

Then in your controller just change controllerProperty, automatically this will be reflected in your view.