I am quiet new Ember frame work. I am trying to pass an “action” from the controller to the grandchild component of the current template. But it fails for some reason. 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={{this.field}} @save={{this.save}} />
ChildComponent.hbs
<GrandChildComponent @field={{this.field}} @save={{this.save}} />
GrandChildComponent.hbs
<button @onClick={{action "doSomething" (readonly @field)}}>Save</button>
export default class GrandChildComponent extends Component {
@action
doSomething(fieldName) {
console.log(fieldName); // logs as "userId"
console.log(this.args.save) // undefined
}
}