Skip to content

Commit f136206

Browse files
committed
#5490 initial example
1 parent bfb84a7 commit f136206

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Inline Model
2+
3+
<pre data-neo>
4+
import Container from '../../../../src/container/Base.mjs';
5+
import Label from '../../../../src/component/Label.mjs';
6+
7+
class MainView extends Container {
8+
static config = {
9+
className: 'Example.view.MainView',
10+
model: {
11+
data: {
12+
hello: 'Hello',
13+
world: 'world!'
14+
}
15+
},
16+
itemDefaults: {
17+
module: Label,
18+
style : {margin: '1em'}
19+
},
20+
items: [{
21+
bind: {
22+
// We can use template literals containing VM data props
23+
text: data => `${data.hello} ${data.world}`
24+
}
25+
}, {
26+
bind: {
27+
// We can also use VM data props directly inside fat arrow functions
28+
text: data => data.hello + ' ' + data.world
29+
}
30+
}, {
31+
bind: {
32+
// We can convert the config into a function to use VM data props
33+
text(data) {return data.hello + ' ' + data.world}
34+
}
35+
}],
36+
layout: 'vbox'
37+
}
38+
}
39+
Neo.setupClass(MainView);
40+
</pre>

resources/data/deck/learnneo/tree.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
{"name": "User Input (Forms)", "parentId": "InDepth", "isLeaf": false, "id": "Forms"},
2727
{"name": "Component and Container Basics", "parentId": "InDepth", "isLeaf": true, "id": "ComponentsAndContainers"},
2828
{"name": "Layouts", "parentId": "InDepth", "isLeaf": false, "id": "Layouts"},
29+
{"name": "View Models", "parentId": "InDepth", "isLeaf": true, "id": "GuideViewModels"},
2930
{"name": "Custom Components", "parentId": "InDepth", "isLeaf": true, "id": "CustomComponents"},
3031
{"name": "Events", "parentId": "InDepth", "isLeaf": true, "expanded": false, "id": "GuideEvents"},
3132
{"name": "Tables (Stores)", "parentId": "InDepth", "isLeaf": false, "id": "Tables"},

0 commit comments

Comments
 (0)