Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit 112119d

Browse files
author
Kamil Kisiela
committed
demo(input): add validation and more options
1 parent 1648861 commit 112119d

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

demo/client/data/examples/input.js

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
const { SetModule } = angular2now;
22

33
SetModule('demo').run(['Examples', 'Menu', (Examples, Menu) => {
4+
const fields = [];
5+
6+
fields.push({
7+
key: 'name',
8+
type: 'input',
9+
templateOptions: {
10+
label: 'Name',
11+
pattern: '[a-zA-Z]+'
12+
},
13+
validation: {
14+
messages: {
15+
pattern: () => 'a-zA-Z only'
16+
}
17+
}
18+
});
19+
20+
fields.push({
21+
key: 'sum',
22+
type: 'input',
23+
templateOptions: {
24+
type: 'number',
25+
label: 'Sum',
26+
step: 0.5,
27+
min: 0,
28+
max: 10
29+
},
30+
validation: {
31+
messages: {
32+
max: () => '10 is max',
33+
min: () => '0 is min',
34+
number: () => 'Invalid format'
35+
}
36+
}
37+
});
38+
439
// set example
540
Examples.set('input', {
6-
fields: [{
7-
key: 'text',
8-
type: 'input',
9-
templateOptions: {
10-
label: 'Text'
11-
}
12-
}]
41+
fields
1342
}, 'types/input.md');
1443

1544
// add menu item to types

0 commit comments

Comments
 (0)