Skip to content

Instantly share code, notes, and snippets.

@Tallyb
Created June 10, 2019 15:48
Show Gist options
  • Save Tallyb/3fae25ad93760c4f93ba3a49c6b67cd9 to your computer and use it in GitHub Desktop.
Save Tallyb/3fae25ad93760c4f93ba3a49c6b67cd9 to your computer and use it in GitHub Desktop.
Input component
import { Component, Prop, h, JSX, Event, EventEmitter } from '@stencil/core';
@Component({
tag: 'my-input',
styleUrl: 'input.css',
shadow: true
})
export class MyInput {
@Prop() header: string;
@Event() thisHappened: EventEmitter<any>;
private inputElement: HTMLInputElement;
onInputChanged = () => {
let value = this.inputElement.value;
this.thisHappened.emit(value);
}
render() : JSX.Element {
return (
<div class="nice">
<input
onInput={this.onInputChanged}
ref={el => this.inputElement = el as HTMLInputElement}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment