Skip to content

Commit c23b904

Browse files
committed
feat(demo): improve dynamic example docs
1 parent 1f383aa commit c23b904

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,39 @@ <h2>Dynamic element tag</h2>
1919
</div>
2020
<div class="implementation" *ngIf="example1">
2121
<ng-template #loading>Loading...</ng-template>
22-
<div
22+
<ax-lazy-element
2323
*axLazyElementDynamic="
2424
'mwc-button';
2525
url: 'https://unpkg.com/@material/mwc-button@0.6.0/mwc-button.js?module';
2626
loadingTemplate: loading;
2727
module: true
2828
"
29-
outlined
29+
[outlined]="true"
3030
(click)="increment1()"
3131
>
3232
Increment
33-
</div>
33+
</ax-lazy-element>
3434
<p>Counter: {{ counter1 }}</p>
3535
</div>
3636
<div class="description">
3737
<p>
3838
In this example we're loading
3939
<code>&#60;mwc-button></code> using the
4040
<code>*axLazyElementDynamic</code> directive. Please notice that the
41-
original HTML element used in the template is <code>&#60;div></code> and
42-
we're specifying the desired tag as the first parameter of
41+
original HTML element used in the template is
42+
<code>&#60;ax-lazy-element></code> and we're specifying the desired tag
43+
as the first parameter of
4344
<code>*axLazyElementDynamic='mwc-button'</code>. Please, feel free to
4445
open your browsers dev tools to check resulting element tag!
4546
</p>
4647
<pre [highlight]="codeExample1"></pre>
48+
<p>
49+
You might be asking why do we use <code>&#60;ax-lazy-element></code>.
50+
This is not a real custom element and that's exactly the point. We can
51+
provide any valid and unused custom element name. That way Angular won't
52+
complain if we use custom property and event binding which would be the
53+
case if we tried to bind <code>&#60;div [custom]="value"></code>...
54+
</p>
4755
</div>
4856
</div>
4957

@@ -57,12 +65,12 @@ <h2>Dynamic element tag with module configuration</h2>
5765
</div>
5866
<div class="implementation" *ngIf="example2">
5967
<ng-template #loading>Loading...</ng-template>
60-
<div
68+
<ax-lazy-element
6169
*axLazyElementDynamic="'wired-button'; loadingTemplate: loading"
6270
(click)="increment2()"
6371
>
6472
Increment
65-
</div>
73+
</ax-lazy-element>
6674
<p>Counter: {{ counter2 }}</p>
6775
</div>
6876
<div class="description">

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ export class DynamicComponent implements OnInit {
3333
}
3434

3535
export const CODE_EXAMPLE_1 = `<!-- url = 'https://unpkg.com/@material/mwc-button@0.6.0/mwc-button.js?module' -->;
36-
<div *axLazyElementDynamic="'mwc-button', url: url; module: true"
37-
outlined
36+
<ax-lazy-element *axLazyElementDynamic="'mwc-button', url: url; module: true"
37+
[outlined]="true"
3838
(click)="increment()">
3939
Increment
40-
</div>
40+
</ax-lazy-element>
4141
4242
<!-- will be rendered as ...
4343
<mwc-button outlined (click)="increment()">Increment</mwc-button>
4444
-->`;
4545

46-
export const CODE_EXAMPLE_2_HTML = `<div *axLazyElementDynamic="'wired-button'" (click)="increment()">
46+
export const CODE_EXAMPLE_2_HTML = `<ax-lazy-element *axLazyElementDynamic="'wired-button'" (click)="increment()">
4747
Increment
48-
</div>
48+
</ax-lazy-element>
4949
5050
<!-- will be rendered as ...
5151
<wired-button (click)="increment()">Increment</wired-button>

projects/elements-demo/src/app/features/examples/dynamic/dynamic.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModule } from '@angular/core';
1+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
22
import { HighlightModule } from 'ngx-highlightjs';
33

44
import {
@@ -22,6 +22,7 @@ const options: LazyElementModuleOptions = {
2222
};
2323

2424
@NgModule({
25+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
2526
declarations: [DynamicComponent],
2627
imports: [
2728
HighlightModule,

0 commit comments

Comments
 (0)