Created
June 10, 2019 15:48
-
-
Save Tallyb/3fae25ad93760c4f93ba3a49c6b67cd9 to your computer and use it in GitHub Desktop.
Input component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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