How to do the Synchronous call in the Ember js

487 Views Asked by At

Here what i have done :
I have controller called "employee" and component "Department".

From controller i want to call the function of the component how can i it ?

controller: "Employee" ::

if (this.get("callMoveleft")) {
    this.set("callMoveleft", false);
    }    


else {
       this.set("callMoveleft", true);
      }  

Component : "Department" ::

callMoveLeft: function () {
        console.log('Move left will be called');
    }.observes("callMoveleft"),

Department's function is not getting called. Please suggest me where i am doing wrong ?

1

There are 1 best solutions below

4
On BEST ANSWER

You should have a model that represents your component's state. This model will be available to the controller, so that it can call .moveLeft() on it.

The component should use this model's properties to display itself. Once the controller changes the model's state, the component will automatically update.

UPD

Demo: http://emberjs.jsbin.com/wizepi/1/edit?html,js,output