Skip to content

Commit ec6ad2e

Browse files
committed
feat(picker): custom item template example
1 parent 2069472 commit ec6ad2e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/picker/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,43 @@ Then you will be able to declare the fields in the html of your component:
5555
<PickerField hint="Click here" [items]="pickerItems"></PickerField>
5656
```
5757
58+
### Custom item template
59+
60+
You can also define your own item template in the list that is opened:
61+
62+
```html
63+
<PickerField hint="Click here" class="picker-field" textField="name" [pickerTitle]="'Select item from list'" [items]="items">
64+
<ng-template let-item="item">
65+
<GridLayout columns="auto, *" rows="auto, *">
66+
<Label text="Static text:" col="0"></Label>
67+
<Label [text]="item?.name" col="0" row="1"></Label>
68+
<Image [src]="item?.imageUrl" col="1" row="0" rowSpan="2"></Image>
69+
</GridLayout>
70+
</ng-template>
71+
</PickerField>
72+
```
73+
74+
With the following bindings:
75+
76+
```ts
77+
interface IDataItem {
78+
name: string;
79+
id: number;
80+
description: string;
81+
imageUrl: string;
82+
}
83+
84+
this.items = new ObservableArray<IDataItem>();
85+
for (let i = 0; i < 20; i++) {
86+
this.items.push({
87+
name: 'Item ' + i,
88+
id: i,
89+
description: 'Description ' + i,
90+
imageUrl: 'https://picsum.photos/150/70/?random',
91+
});
92+
}
93+
```
94+
5895
- If you are developing a NativeScript Vue app, you need to install the plugin in you app.js file:
5996
6097
```js

0 commit comments

Comments
 (0)