Skip to content

Instantly share code, notes, and snippets.

/hola-mundo.tsx Secret

Created January 17, 2018 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/82d89f80548ac8e5c5fec6b6f649df24 to your computer and use it in GitHub Desktop.
Save anonymous/82d89f80548ac8e5c5fec6b6f649df24 to your computer and use it in GitHub Desktop.
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