Skip to content

Commit 934063f

Browse files
committed
feat(demo): add examples content
1 parent 123ba09 commit 934063f

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

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

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2>Plain directive</h2>
3030
</div>
3131
</div>
3232

33-
<h2>Use loading <code>&#60;ng-template></code></h2>
33+
<h2>Use loading <code>&#60;ng-template #loading></code></h2>
3434
<div class="content">
3535
<div class="implementation" *ngIf="!example2">
3636
<button mat-flat-button color="accent" (click)="example2 = true">
@@ -39,13 +39,11 @@ <h2>Use loading <code>&#60;ng-template></code></h2>
3939
</button>
4040
</div>
4141
<div class="implementation" *ngIf="example2">
42-
<ng-template #error>Loading failed...</ng-template>
4342
<ng-template #loading>Loading...</ng-template>
4443
<mwc-button
4544
*axLazyElement="
4645
'https://unpkg.com/@material/mwc-button@0.6.0/mwc-button.js?module';
4746
loadingTemplate: loading;
48-
errorTemplate: error;
4947
module: true
5048
"
5149
raised
@@ -61,10 +59,46 @@ <h2>Use loading <code>&#60;ng-template></code></h2>
6159
<code>&#60;mwc-button></code> using the
6260
<code>*axLazyElement</code> directive but we're also adding
6361
<code>&#60;ng-template #loading>Loading...&#60;ng-template></code> which
64-
will display before the element was loaded (depending on your connection
65-
speed)
62+
will be displayed before the element was loaded (depending on your
63+
connection speed)
6664
</p>
6765
<pre [highlight]="codeExample2"></pre>
6866
</div>
6967
</div>
68+
69+
<h2>Use error <code>&#60;ng-template #error></code></h2>
70+
<div class="content">
71+
<div class="implementation" *ngIf="!example3">
72+
<button mat-flat-button color="accent" (click)="example3 = true">
73+
<mat-icon>play_arrow</mat-icon>
74+
Run
75+
</button>
76+
</div>
77+
<div class="implementation" *ngIf="example3">
78+
<ng-template #loading>Loading...</ng-template>
79+
<ng-template #error>Loading failed...</ng-template>
80+
<mwc-button
81+
*axLazyElement="
82+
'https://unpkg.com/wrong-url.js?module';
83+
loadingTemplate: loading;
84+
errorTemplate: error;
85+
module: true
86+
"
87+
raised
88+
>
89+
Submit
90+
</mwc-button>
91+
</div>
92+
<div class="description">
93+
<p>
94+
In this example we're loading
95+
<code>&#60;mwc-button></code> using the
96+
<code>*axLazyElement</code> directive but we're also adding
97+
<code>&#60;ng-template #error>Loading failed...&#60;ng-template></code>
98+
which will be displayed because the loading request will fail (wrong
99+
url)
100+
</p>
101+
<pre [highlight]="codeExample3"></pre>
102+
</div>
103+
</div>
70104
</div>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ export class BasicComponent implements OnInit {
99
// example toggles
1010
example1 = false;
1111
example2 = false;
12+
example3 = false;
1213

1314
// example state
1415
counter = 0;
1516

1617
// example code examples
1718
codeExample1 = CODE_EXAMPLE_1;
1819
codeExample2 = CODE_EXAMPLE_2;
20+
codeExample3 = CODE_EXAMPLE_3;
1921

2022
constructor() {}
2123

@@ -37,3 +39,9 @@ const CODE_EXAMPLE_2 = `<!-- url = 'https://unpkg.com/@material/mwc-button@0.6.0
3739
(click)="increment()">
3840
Increment
3941
</mwc-button>`;
42+
43+
const CODE_EXAMPLE_3 = `<!-- url = 'https://unpkg.com/wrong-url.js?module' -->;
44+
<ng-template #error>Loading failed...</ng-template>
45+
<mwc-button *axLazyElement="url; errorTemplate: error; module: true">
46+
Submit
47+
</mwc-button>`;

0 commit comments

Comments
 (0)