Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember JS creating a "private" function inside controller

I have an ember controller which has some actions. Inside those actions I want to be able to call another function to regroup functionality but I don't want to do it through this.send('someAction'), I just want to call it directly and not have anything except that controller call that function.

actions: {
  my_btn_click: function(){
    this.set('somthing', 'something else');
    //functionA call here, not this.send('something');
  }
},
//declare functionA here ? doesnt work.
like image 979
Dr.Denis McCracleJizz Avatar asked Feb 08 '23 05:02

Dr.Denis McCracleJizz


1 Answers

Ember objects are just extensions to plain JS objects, meaning you can define methods on them and call them (through this) as you would on regular objects:

functionA: function() {

}

actions: {
  my_btn_click: function(){
    this.functionA();
  }
},
like image 50
nem035 Avatar answered Feb 11 '23 00:02

nem035