I am working on passing actions in component inside component. In the general, I am using the method like that
home.hbs:
home.js
actions:{
action1: function () {
//do something
},
action2: function () {
//do something
},
action3: function () {
//do something
},
action4: function () {
//do something
}
}
layerOne.hbs
layerOne.js
actions:{
action1: function () {
this.sendAction('action1');
},
action2: function () {
this.sendAction('action2');
},
action3: function () {
this.sendAction('action3');
},
action4: function () {
this.sendAction('action4');
}
}
layerTwo.hbs
Action 1
Action 2
Action 3
Action 4
layerTwo.js
actions:{
action1: function () {
this.sendAction('action1');
},
action2: function () {
this.sendAction('action2');
},
action3: function () {
this.sendAction('action3');
},
action4: function () {
this.sendAction('action4');
}
}
If I add more actions, I have to config the layers' js file and hbs file one by one every time. Also the hbs will be very long. eg.
Is there any best practice for this case? Thank you.
Aucun commentaire:
Enregistrer un commentaire