-
-
Save anonymous/82d89f80548ac8e5c5fec6b6f649df24 to your computer and use it in GitHub Desktop.
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, State} from '@stencil/core' | |
@Component({ | |
tag: 'hola-mundo', | |
styleUrl: 'hola-mundo.scss' | |
}) | |
export class HolaMundo { | |
@State() todo: string = ''; | |
@State() todos = []; | |
inputChanged(event) { | |
this.todo = event.target.value; | |
} | |
addTodo() { | |
this.todos = [ | |
...this.todos, | |
this.todo | |
]; | |
this.todo = ''; | |
} | |
render () { | |
return ( | |
<div> | |
<h1>Hola Mundo con StencilJS</h1> | |
<input type="text" value={this.todo} onInput={() => this.inputChanged(event)} /> | |
<button onClick={this.addTodo.bind(this)}>Añadir todo</button> | |
{this.todos.map((todo) => | |
<div> | |
<div>{todo}</div> | |
</div> | |
)} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment