lundi 13 janvier 2020

How to pass an "action" from a template to it's grand child components in Ember Octane

I am trying to pass an "action" from the controller to the grandchild component of the current template. But it fails for somereason. Could anyone let me know what am I missing here.

MainTemplate's Router Controller

export default class MainTemplateController extends Controller {

  field = "userId";

  @action
  save () {
    //save data
  }

}

MainTemplate.hbs

<ChildComponent @field= @save= /> 


ChildComponent.hbs 

<GrandChildComponent @field= @save= />


GrandChildComponent.hbs

<button @onClick=>Save</button>

export default class GrandChildComponent extends Component {    
    @action
    doSomething(fieldName) {
        console.log(fieldName); // logs as "userId"
        console.log(this.args.save) // undefined
    }    
}



Aucun commentaire:

Enregistrer un commentaire