Skip to content

Instantly share code, notes, and snippets.

@vivainio
Created September 17, 2017 09:26
Show Gist options
  • Select an option

  • Save vivainio/745399b7861af10aa7a3344842943c64 to your computer and use it in GitHub Desktop.

Select an option

Save vivainio/745399b7861af10aa7a3344842943c64 to your computer and use it in GitHub Desktop.
import { Component, Prop, EventEmitter, Event } from "@stencil/core";
@Component({
tag: 'my-name',
styleUrl: 'my-name.scss'
})
export class MyName {
@Prop() simplestring: string;
@Prop() strings: string[];
@Event() onListClick: EventEmitter;
listClick(e) {
console.log('list item clicked in stencil');
this.onListClick.emit(e);
}
render() {
return (
<div>
<p>Simple string is {this.simplestring}</p>
{ this.strings ? (
<ul>
{ this.strings.map(s => <li onClick={ e => this.listClick(e) }>
{s}
</li>) }
</ul>) : <p onClick={_ => this.listClick(null) }>No strings yet</p>}
<slot></slot>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment