You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: angular/README.md
+34-22Lines changed: 34 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,27 @@
1
1
# Angular wrapper
2
2
3
-
The Angular [wrapper component](projects/lib/src/lib/gridstack.component.ts) <gridstack> is a better way to use Gridstack, but alternative raw [ngFor](projects/demo/src/app/ngFor.ts) or [simple](projects/demo/src/app/simple.ts) demos are also given.
3
+
The Angular [wrapper component](projects/lib/src/lib/gridstack.component.ts) <gridstack> is a <b>better way to use Gridstack</b>, but alternative raw [ngFor](projects/demo/src/app/ngFor.ts) or [simple](projects/demo/src/app/simple.ts) demos are also given.
4
4
5
5
# Dynamic grid items
6
+
6
7
this is the recommended way if you are going to have multiple grids (alow drag&drop between) or drag from toolbar to create items, or drag to remove items, etc...
7
8
8
9
I.E. don't use Angular templating to create grid items as that is harder to sync when gridstack will also add/remove items.
9
10
10
-
HTML
11
+
HTML
12
+
11
13
```html
12
-
<gridstack[options]="gridOptions">
13
-
</gridstack>
14
+
<gridstack[options]="gridOptions"></gridstack>
14
15
```
15
16
16
17
CSS
18
+
17
19
```css
18
20
@import"gridstack/dist/gridstack.min.css";
21
+
@import"gridstack/dist/gridstack-extra.min.css"; // if you use 2-11 column
@@ -54,16 +59,19 @@ public gridOptions: GridStackOptions = {
54
59
```
55
60
56
61
# More Complete example
62
+
57
63
In this example (build on previous one) will use your actual custom angular components inside each grid item (instead of dummy html content) and have per component saved settings as well (using BaseWidget).
@@ -149,22 +158,25 @@ public identify(index: number, w: GridStackWidget) {
149
158
```
150
159
151
160
## Demo
161
+
152
162
You can see a fuller example at [app.component.ts](projects/demo/src/app/app.component.ts)
153
163
154
-
to build the demo, go to [angular/projects/demo](projects/demo/) and run `yarn` + `yarn start` and navigate to `http://localhost:4200/`
164
+
to build the demo, go to [angular/projects/demo](projects/demo/) and run `yarn` + `yarn start` and navigate to `http://localhost:4200/`
155
165
156
166
Code ship starting with v8.1.2+ in `dist/angular` for people to use directly and is an angular module! (source code under `dist/angular/src`)
157
-
## Caveats
158
167
159
-
- This wrapper needs:
160
-
- gridstack v8 to run as it needs the latest changes (use older version that matches GS versions)
161
-
- Angular 13+ for dynamic createComponent() API
168
+
## Caveats
169
+
170
+
- This wrapper needs:
171
+
- gridstack v8 to run as it needs the latest changes (use older version that matches GS versions)
172
+
- Angular 13+ for dynamic createComponent() API
173
+
174
+
## ngFor Caveats
175
+
176
+
- This wrapper handles well ngFor loops, but if you're using a trackBy function (as I would recommend) and no element id change after an update,
177
+
you must manually update the `GridstackItemComponent.option` directly - see [modifyNgFor()](./projects/demo/src/app/app.component.ts#L202) example.
178
+
- The original client list of items is not updated to match **content** changes made by gridstack (TBD later), but adding new item or removing (as shown in demo) will update those new items. Client could use change/added/removed events to sync that list if they wish to do so.
162
179
163
-
## *ngFor Caveats
164
-
- This wrapper handles well ngFor loops, but if you're using a trackBy function (as I would recommend) and no element id change after an update,
165
-
you must manually update the `GridstackItemComponent.option` directly - see [modifyNgFor()](src/app/app.component.ts#L174) example.
166
-
- The original client list of items is not updated to match **content** changes made by gridstack (TBD later), but adding new item or removing (as shown in demo) will update those new items. Client could use change/added/removed events to sync that list if they wish to do so.
180
+
Would appreciate getting help doing the same for React and Vue (2 other popular frameworks)
167
181
168
-
Would appreciate getting help doing the same for React and Vue (2 other popular frameworks)
0 commit comments