0

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

user51854
  • 319
  • 1
  • 4
  • 11

1 Answers1

0

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.

Griffosx
  • 1,605
  • 1
  • 16
  • 23
  • Shouldn't it be as follows? `{{#view "myView" fooBinding=controllerProperty}} {{view.propertyThatDependsOnFoo}} {{/view}}` – undeletable Nov 14 '14 at 23:14