mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
add router service, better structure for demo app
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import Widget from "../../../src/core/widget";
|
||||
|
||||
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 default class Counter extends Widget {
|
||||
name = "counter";
|
||||
template = template;
|
||||
state = {
|
||||
counter: 0
|
||||
};
|
||||
|
||||
constructor(parent: Widget | null, props: {initialState?: number}) {
|
||||
super(parent);
|
||||
this.state.counter = props.initialState || 0;
|
||||
}
|
||||
|
||||
increment(delta: number) {
|
||||
this.updateState({ counter: this.state.counter + delta });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user