Files
owl/examples/demo/counter.js
T
2019-03-18 14:26:33 +01:00

21 lines
525 B
JavaScript

const template = `
<div>
<button t-on-click="increment(-1)">-</button>
<span style="font-weight:bold">Value: <t t-esc="state.counter"/></span>
<button t-on-click="increment(1)">+</button>
</div>`;
export class Counter extends odoo.core.Component {
constructor(parent, props) {
super(parent, props);
this.inlineTemplate = template;
this.state = {
counter: props.initialState || 0
};
}
increment(delta) {
this.setState({ counter: this.state.counter + delta });
}
}