Skip to content

Instantly share code, notes, and snippets.

@Tallyb
Last active June 7, 2019 18:11
Show Gist options
  • Save Tallyb/d34c308a54c4d3ed3d86eb6f7de61553 to your computer and use it in GitHub Desktop.
Save Tallyb/d34c308a54c4d3ed3d86eb6f7de61553 to your computer and use it in GitHub Desktop.
Event method component
import { Component, State, Event, Method, EventEmitter, h , JSX } from '@stencil/core';
@Component({
tag: 'my-event',
styleUrl: 'event.css'
})
export class MyEvent {
@State() buttonFace: string = 'Click Me!';
@State() clicked: boolean;
@Event() buttonClicked: EventEmitter<string>;
@Method()
async updateFace(value: string): Promise<string>{
this.buttonFace = value;
return this.buttonFace.toUpperCase();
}
onClicked(value: string) {
console.log('value is: ', value);
this.clicked = !this.clicked;
this.buttonClicked.emit('Yep!')
}
render(): JSX.Element {
return (
<button onClick={()=>this.onClicked('ABCD')}>
{this.buttonFace}
</button>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment