Skip to content

Commit 6a07adb

Browse files
committed
feat(demo): add advanced property binding example
1 parent 6ace3ba commit 6a07adb

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

projects/elements-demo/src/app/features/examples/basic/basic.component.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,46 @@ <h2>Use error <code>&#60;ng-template #error></code></h2>
101101
<pre [highlight]="codeExample3"></pre>
102102
</div>
103103
</div>
104+
105+
<h2>Advanced binding (objects instead of primitives)</h2>
106+
<div class="content">
107+
<div class="implementation" *ngIf="!example4">
108+
<button mat-flat-button color="accent" (click)="example4 = true">
109+
<mat-icon>play_arrow</mat-icon>
110+
Run
111+
</button>
112+
</div>
113+
<div class="implementation" *ngIf="example4">
114+
<ng-template #loading>Loading...</ng-template>
115+
<ng-template #error>Loading failed...</ng-template>
116+
<ion-item
117+
*axLazyElement="
118+
'https://unpkg.com/@ionic/core@4.6.2/dist/ionic/ionic.js';
119+
loadingTemplate: loading;
120+
errorTemplate: error
121+
"
122+
>
123+
<ion-label>Pick a year&nbsp;</ion-label>
124+
<ion-datetime
125+
[displayFormat]="'YYYY'"
126+
[pickerFormat]="'YYYY'"
127+
[yearValues]="customYearValues"
128+
>
129+
</ion-datetime>
130+
</ion-item>
131+
</div>
132+
<div class="description">
133+
<p>
134+
In this example we're loading ionic! Ionic comes with all elements in
135+
single bundle so we can use multiple ionic elements while using
136+
<code>*axLazyElement</code> directive only on the outmost element.
137+
Besides that in our Angular component we have defined
138+
<code>customYearValues</code> array with the
139+
<code>[2020, 2030, 2040]</code> values which are passed in the element
140+
using standard Angular property binding
141+
<code>[yearValues]="customYearValues"</code>.
142+
</p>
143+
<pre [highlight]="codeExample4"></pre>
144+
</div>
145+
</div>
104146
</div>

projects/elements-demo/src/app/features/examples/basic/basic.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ export class BasicComponent implements OnInit {
1010
example1 = false;
1111
example2 = false;
1212
example3 = false;
13+
example4 = false;
1314

1415
// example state
1516
counter = 0;
17+
customYearValues = [2020, 2030, 2040];
1618

1719
// example code examples
1820
codeExample1 = CODE_EXAMPLE_1;
1921
codeExample2 = CODE_EXAMPLE_2;
2022
codeExample3 = CODE_EXAMPLE_3;
23+
codeExample4 = CODE_EXAMPLE_4;
2124

2225
constructor() {}
2326

@@ -45,3 +48,15 @@ const CODE_EXAMPLE_3 = `<!-- url = 'https://unpkg.com/wrong-url.js?module' -->;
4548
<mwc-button *axLazyElement="url; errorTemplate: error; module: true">
4649
Submit
4750
</mwc-button>`;
51+
52+
const CODE_EXAMPLE_4 = `<!-- url = 'https://unpkg.com/@ionic/core@4.6.2/dist/ionic/ionic.js' -->;
53+
<!-- customYearValues = [2020, 2030, 2040] -->;
54+
<ion-item *axLazyElement="url">
55+
<ion-label>Pick a year</ion-label>
56+
<ion-datetime
57+
[displayFormat]="'YYYY'"
58+
[pickerFormat]="'YYYY'"
59+
[yearValues]="customYearValues"
60+
>
61+
</ion-datetime>
62+
</ion-item>`;

projects/elements-demo/src/styles-reset.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ blockquote {
5959
}
6060
}
6161
}
62+
63+
// CUSTOMIZE CONSUMED WEB COMPONENTS
64+
ion-picker {
65+
position: fixed !important;
66+
}

0 commit comments

Comments
 (0)