File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,14 @@ export class Counter extends Component {
55 static template = "awesome_owl.counter" ;
66
77 setup ( ) {
8- this . state = useState ( { counter : 0 } ) ;
8+ this . state = useState ( { counter : 1 } ) ;
99 }
1010
1111 incrementCounter ( ) {
1212 this . state . counter ++ ;
13+ this . props . callback ( ) ;
1314 }
15+
16+ static props = { callback : Function } ;
17+
1418}
Original file line number Diff line number Diff line change 1- import { Component , useState } from "@odoo/owl" ;
1+ import { Component , useState , markup } from "@odoo/owl" ;
22import { Counter } from "./counter/counter" ;
33import { Card } from "./card/card" ;
44
5-
65export class Playground extends Component {
76 static template = "awesome_owl.playground" ;
87 static components = { Counter, Card } ;
8+ no_markup_value = "<div class='text-primary'>Testing no markup</div>" ;
9+ markup_value = markup ( "<div class='text-primary'>Testing markup</div>" ) ;
910 setup ( ) {
11+ this . state = useState ( { sum : 2 } ) ;
12+ this . incrementSum = this . incrementSum . bind ( this ) ;
13+ }
1014
15+ incrementSum ( ) {
16+ this . state . sum += 1 ;
1117 }
1218}
Original file line number Diff line number Diff line change 33 <t t-name =" awesome_owl.playground" >
44 Hello My Friend
55 <div >
6- <Counter />
7- <Counter />
6+ <Counter callback.bind= " incrementSum " />
7+ <Counter callback.bind= " incrementSum " />
88 </div >
99 <div >
10- <Card title =" 'Task 1'" content =" 'prepare things' " />
11- <Card title =" 'Task 2'" content =" 'do stuff' " />
10+ <Card title =" 'Task 1'" content =" no_markup_value " />
11+ <Card title =" 'Task 2'" content =" markup_value " />
1212 </div >
13+ <p >Sum: <t t-esc =" state.sum" /></p >
1314 </t >
1415</templates >
You can’t perform that action at this time.
0 commit comments