From ee855233a67e7963e35163b059ad748206331e4a Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Thu, 24 Oct 2024 17:22:06 -0700 Subject: [PATCH] using angular 17 demo syntax * demos are using new syntax, readme has both * left the wrapper angular 14-18+ compatible. --- angular/README.md | 5 + .../projects/demo/src/app/app.component.html | 201 +++++++++--------- angular/projects/demo/src/app/ngFor.ts | 30 ++- angular/projects/demo/src/app/ngFor_cmd.ts | 27 +-- 4 files changed, 135 insertions(+), 128 deletions(-) diff --git a/angular/README.md b/angular/README.md index b7c1031c2..00b89ecb3 100644 --- a/angular/README.md +++ b/angular/README.md @@ -129,6 +129,11 @@ HTML ```html + + @for (n of items; track n.id) { + Item {{n.id}} + } + Item {{n.id}} ``` diff --git a/angular/projects/demo/src/app/app.component.html b/angular/projects/demo/src/app/app.component.html index c22f9f547..f079bc614 100644 --- a/angular/projects/demo/src/app/app.component.html +++ b/angular/projects/demo/src/app/app.component.html @@ -14,111 +14,116 @@
- - - - -
-

COMPONENT template: using DOM template to use components statically

- - - - - - item 1 - item 2 wide - -
- -
-

COMPONENT ngFor: Most complete example that uses Component wrapper for grid and gridItem

- - - - - - - - -
- -
-

COMPONENT dynamic: Best example that uses Component wrapper and dynamic grid creation (drag between grids, from toolbar, etc...)

- - - - - - - - - -
- - -
-

Nested Grid: shows nested component grids, like nested.html demo but with Ng Components

- - - - - - - - - - - - - -
Add items here or reload the grid
-
-
+ @if (show===0) { + + } @else if (show===1) { + + } @else if (show===2) { + + } @else if (show===3) { +
+

COMPONENT template: using DOM template to use components statically

+ + + + + + item 1 + item 2 wide + +
+ } @else if (show===4) { +
+

COMPONENT ngFor: Most complete example that uses Component wrapper for grid and gridItem

+ + + + + + @for (n of items; track n.id) { + + } + +
+ } @else if (show===5) { +
+

COMPONENT dynamic: Best example that uses Component wrapper and dynamic grid creation (drag between grids, from toolbar, etc...)

+ + + + + + + + + +
+ } @else if (show===6) { +
+

Nested Grid: shows nested component grids, like nested.html demo but with Ng Components

+ + + + + + + + + + -
-

two.html: shows multiple grids, sidebar creating Components

-
-
- + + +
Add items here or reload the grid
+
-
-
+ } @else if (show===7) { +
+

two.html: shows multiple grids, sidebar creating Components

+
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
-
-
-
- + } @else if (show===8) { +
+

delay loading of components

+
+ +
-
- + } @else if (show===9) { +
+

load() + clear() to memory leak test between the two

+ + + +
-
-
-
-

delay loading of components

-
- -
-
+
-
-

load() + clear() to memory leak test between the two

- - - - -
- -
- -
- - -
+} @else if (show!=8) { +
+ + +
+}
diff --git a/angular/projects/demo/src/app/ngFor.ts b/angular/projects/demo/src/app/ngFor.ts index 2eeff838c..a51c8142b 100644 --- a/angular/projects/demo/src/app/ngFor.ts +++ b/angular/projects/demo/src/app/ngFor.ts @@ -20,19 +20,20 @@ let ids = 1; -
-
item {{ n.id }}
-
+ @for (n of items; track n.id) { +
+
item {{ n.id }}
+
+ }
- `, + `, // gridstack.min.css and other custom styles should be included in global styles.scss or here }) export class AngularNgForTestComponent implements AfterViewInit { @@ -123,9 +124,4 @@ export class AngularNgForTestComponent implements AfterViewInit { {x:3, y:0, w:3}, // new item ]; } - - // ngFor unique node id to have correct match between our items used and GS - identify(index: number, w: GridStackWidget) { - return w.id; - } } diff --git a/angular/projects/demo/src/app/ngFor_cmd.ts b/angular/projects/demo/src/app/ngFor_cmd.ts index b0df6c1f6..4e9e77d8e 100644 --- a/angular/projects/demo/src/app/ngFor_cmd.ts +++ b/angular/projects/demo/src/app/ngFor_cmd.ts @@ -17,20 +17,21 @@ import { GridItemHTMLElement, GridStack, GridStackWidget } from 'gridstack';
-
-
item {{ i }}
-
+ @for (n of items; track n.id; let i = $index) { +
+
item {{ i }}
+
+ }
- `, + `, // gridstack.min.css and other custom styles should be included in global styles.scss or here }) export class AngularNgForCmdTestComponent implements AfterViewInit {