Let's say I have a simple component in glimmer with a list of items
component.ts
import Component, { tracked } from '@glimmer/component';
export default class TodoList extends Component {
constructor(options) {
super(options);
}
clickme() {
// how do I access the parent context from here?
}
}
template.hbs
<ul>
<li onclick=></li>
</ul>
Even if I pass in an action from the parent
<todo-list @items= @rootclickme=></todo-list>
updated, template.hbs
<ul>
<li onclick=></li>
</ul>
in my outer component.ts
rootclickme () {
// I don't have access to parent variables here either?
// only what's within the scope of the function itself?
}
What I'm trying to do is have a component which contains a list have some effect on another component. I want it to bubble up a click event to the top, so that the parent component can decide to hide the list and show a more detailed view for a todo item.
How do I go about doing this?
Note: I'm not using full ember.js, just glimmer.js standalone
Aucun commentaire:
Enregistrer un commentaire