|
1 |
| -<div class="wrapper"> |
2 |
| - <h1>Advanced</h1> |
3 |
| - |
4 |
| - <h2>Elements configured in module</h2> |
5 |
| - <div class="content"> |
6 |
| - <div class="implementation" *ngIf="!example1"> |
7 |
| - <button mat-flat-button color="accent" (click)="example1 = true"> |
8 |
| - <mat-icon>play_arrow</mat-icon> |
9 |
| - Run |
10 |
| - </button> |
11 |
| - </div> |
12 |
| - <div class="implementation" *ngIf="example1"> |
13 |
| - <ion-button *axLazyElement (click)="increment()">Click me</ion-button> |
14 |
| - <p>Counter: {{ counter }}</p> |
15 |
| - </div> |
16 |
| - <div class="description"> |
17 |
| - <p> |
18 |
| - In this example we're pre-configuring |
19 |
| - <code>LazyElementsModule</code> with the element config. That way we |
20 |
| - don't have to specify url of the element in the |
21 |
| - <code>*axLazyElement</code> directive. The element will be lazy-loaded |
22 |
| - the same way as if we specified url directly. |
23 |
| - </p> |
24 |
| - <pre [highlight]="codeExample1html"></pre> |
25 |
| - <pre [highlight]="codeExample1module"></pre> |
26 |
| - </div> |
27 |
| - </div> |
28 |
| - |
29 |
| - <h2>Elements configured in module with HTML inline options</h2> |
30 |
| - <div class="content"> |
31 |
| - <div class="implementation" *ngIf="!example2"> |
32 |
| - <button mat-flat-button color="accent" (click)="example2 = true"> |
33 |
| - <mat-icon>play_arrow</mat-icon> |
34 |
| - Run |
35 |
| - </button> |
36 |
| - </div> |
37 |
| - <div class="implementation" *ngIf="example2"> |
38 |
| - <ng-template #loading>Loading...</ng-template> |
39 |
| - <mwc-checkbox |
40 |
| - *axLazyElement="null; module: true; loadingTemplate: loading" |
41 |
| - >Click me</mwc-checkbox |
42 |
| - > |
43 |
| - </div> |
44 |
| - <div class="description"> |
45 |
| - <p> |
46 |
| - We don't have to specify <code>url</code> when using pre-configured |
47 |
| - <code>LazyElementsModule</code>. We still might need to pass in |
48 |
| - <code>null</code> url into <code>*axLazyElement</code> directive in case |
49 |
| - we want to use other options like <code>module</code> or |
50 |
| - <code>loadingTemplate</code>. |
51 |
| - </p> |
52 |
| - <pre [highlight]="codeExample2html"></pre> |
53 |
| - <pre [highlight]="codeExample2module"></pre> |
54 |
| - <pre [highlight]="codeExample2coreModule"></pre> |
55 |
| - </div> |
56 |
| - </div> |
57 |
| - |
58 |
| - <h2>Elements configured in module with <code>isModule</code> option</h2> |
59 |
| - <div class="content"> |
60 |
| - <div class="implementation" *ngIf="!example3"> |
61 |
| - <button mat-flat-button color="accent" (click)="example3 = true"> |
62 |
| - <mat-icon>play_arrow</mat-icon> |
63 |
| - Run |
64 |
| - </button> |
65 |
| - </div> |
66 |
| - <div class="implementation" *ngIf="example3"> |
67 |
| - <ng-template #loading>Loading...</ng-template> |
68 |
| - <mwc-switch *axLazyElement="null; loadingTemplate: loading"> |
69 |
| - Click me</mwc-switch |
70 |
| - > |
71 |
| - </div> |
72 |
| - <div class="description"> |
73 |
| - <p> |
74 |
| - We can also pre-configure <code>isModule</code> flag by passing it to |
75 |
| - the <code>LazyElementsModule</code>config. That way we don't have to |
76 |
| - specify it in the template for module style elements! |
77 |
| - </p> |
78 |
| - <pre [highlight]="codeExample3html"></pre> |
79 |
| - <pre [highlight]="codeExample3module"></pre> |
80 |
| - </div> |
81 |
| - </div> |
82 |
| -</div> |
| 1 | +<div class="wrapper"> |
| 2 | + <h1>Advanced</h1> |
| 3 | + |
| 4 | + <h2>Elements configured in a feature module</h2> |
| 5 | + <div class="content"> |
| 6 | + <div class="implementation" *ngIf="!example1"> |
| 7 | + <button mat-flat-button color="accent" (click)="example1 = true"> |
| 8 | + <mat-icon>play_arrow</mat-icon> |
| 9 | + Run |
| 10 | + </button> |
| 11 | + </div> |
| 12 | + <div class="implementation" *ngIf="example1"> |
| 13 | + <ion-button *axLazyElement (click)="increment()">Click me</ion-button> |
| 14 | + <p>Counter: {{ counter }}</p> |
| 15 | + </div> |
| 16 | + <div class="description"> |
| 17 | + <p> |
| 18 | + In this example we're pre-configuring |
| 19 | + <code>LazyElementsModule</code> with the element config. That way we |
| 20 | + don't have to specify url of the element in the |
| 21 | + <code>*axLazyElement</code> directive. The element will be lazy-loaded |
| 22 | + the same way as if we specified url directly. |
| 23 | + </p> |
| 24 | + <pre [highlight]="codeExample1html"></pre> |
| 25 | + <pre [highlight]="codeExample1module"></pre> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + |
| 29 | + <h2>Elements configured in a feature module with HTML inline options</h2> |
| 30 | + <div class="content"> |
| 31 | + <div class="implementation" *ngIf="!example2"> |
| 32 | + <button mat-flat-button color="accent" (click)="example2 = true"> |
| 33 | + <mat-icon>play_arrow</mat-icon> |
| 34 | + Run |
| 35 | + </button> |
| 36 | + </div> |
| 37 | + <div class="implementation" *ngIf="example2"> |
| 38 | + <ng-template #loading>Loading...</ng-template> |
| 39 | + <mwc-checkbox |
| 40 | + *axLazyElement="null; module: true; loadingTemplate: loading" |
| 41 | + >Click me</mwc-checkbox |
| 42 | + > |
| 43 | + </div> |
| 44 | + <div class="description"> |
| 45 | + <p> |
| 46 | + We don't have to specify <code>url</code> when using pre-configured |
| 47 | + <code>LazyElementsModule</code>. We still might need to pass in |
| 48 | + <code>null</code> url into <code>*axLazyElement</code> directive in case |
| 49 | + we want to use other options like <code>module</code> or |
| 50 | + <code>loadingTemplate</code>. |
| 51 | + </p> |
| 52 | + <pre [highlight]="codeExample2html"></pre> |
| 53 | + <pre [highlight]="codeExample2module"></pre> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + |
| 57 | + <h2> |
| 58 | + Elements configured in a feature module with <code>isModule</code> option |
| 59 | + </h2> |
| 60 | + <div class="content"> |
| 61 | + <div class="implementation" *ngIf="!example3"> |
| 62 | + <button mat-flat-button color="accent" (click)="example3 = true"> |
| 63 | + <mat-icon>play_arrow</mat-icon> |
| 64 | + Run |
| 65 | + </button> |
| 66 | + </div> |
| 67 | + <div class="implementation" *ngIf="example3"> |
| 68 | + <ng-template #loading>Loading...</ng-template> |
| 69 | + <mwc-switch *axLazyElement="null; loadingTemplate: loading"> |
| 70 | + Click me</mwc-switch |
| 71 | + > |
| 72 | + </div> |
| 73 | + <div class="description"> |
| 74 | + <p> |
| 75 | + We can also pre-configure <code>isModule</code> flag by passing it to |
| 76 | + the <code>LazyElementsModule</code>config. That way we don't have to |
| 77 | + specify it in the template for module style elements! |
| 78 | + </p> |
| 79 | + <pre [highlight]="codeExample3html"></pre> |
| 80 | + <pre [highlight]="codeExample3module"></pre> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + |
| 84 | + <h2> |
| 85 | + Elements configured in <code>AppModule</code> or |
| 86 | + <code>CoreModule</code> using <code>forRoot</code> |
| 87 | + </h2> |
| 88 | + <div class="content"> |
| 89 | + <div class="implementation" *ngIf="!example4"> |
| 90 | + <button mat-flat-button color="accent" (click)="example4 = true"> |
| 91 | + <mat-icon>play_arrow</mat-icon> |
| 92 | + Run |
| 93 | + </button> |
| 94 | + </div> |
| 95 | + <div class="implementation" *ngIf="example4"> |
| 96 | + <mwc-fab icon="code" *axLazyElement></mwc-fab> |
| 97 | + </div> |
| 98 | + <div class="description"> |
| 99 | + <p> |
| 100 | + Some options can be pre-configured for the whole application using |
| 101 | + <code>LazyElementsModule.forRoot()</code>. This is usually done in |
| 102 | + <code>AppModule</code> or in the <code>CoreModule</code>. That way we |
| 103 | + don't have to specify this options in the feature modules while still |
| 104 | + preserving posibility to override them if necessary. The |
| 105 | + <code>forRoot()</code> accepts also <code>elementConfigs</code> so they |
| 106 | + can be pre-configured centrally removing the need to configure them in |
| 107 | + feature modules or inline in the templates. |
| 108 | + </p> |
| 109 | + <pre [highlight]="codeExample4html"></pre> |
| 110 | + <pre [highlight]="codeExample4coreModule"></pre> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | +</div> |
0 commit comments