javascriptember.jsember.js-view

EmberJs: Setting a property of controller from within the view


I am new to emberjs and wanted to set a controller property from within a Ember View. I have been trying to get around it but I am unable to set the controller property from the view. Here is a jsbin of what I am trying to do. http://emberjs.jsbin.com/kiteg/6/. In this app, I wanted to set keyword property to value 'red' from within the sort view. Can someone help me out in getting around it.

Thanks in advance.


Solution

  • You should be able to access your controller properties from the view with

    this.get('controller.myProperty');
    

    Same for setting it

    this.set('controller.myProperty', 'new value');
    

    And here is a correct fiddle : http://jsbin.com/natusuro/1