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
// sync initial actual valued rendered (in case init() had to merge conflicts)
66
+
this.onChange();
72
67
73
68
/**
74
69
* this is called when the list of items changes - get a list of nodes and
75
-
* update the layout accordingly (which will take care of adding/removing/updating items to match DOM done by Angular)
70
+
* update the layout accordingly (which will take care of adding/removing items changed by Angular)
76
71
*/
77
72
this.gridstackItems.changes.subscribe(()=>{
78
73
constlayout: GridStackWidget[]=[];
@@ -84,10 +79,24 @@ export class AngularNgForTestComponent implements AfterViewInit {
84
79
})
85
80
}
86
81
82
+
/** Optional: called when given widgets are changed (moved/resized/added) - update our list to match.
83
+
* Note this is not strictly necessary as demo works without this
84
+
*/
85
+
publiconChange(list=this.grid.engine.nodes){
86
+
setTimeout(()=>// prevent new 'added' items from ExpressionChangedAfterItHasBeenCheckedError. TODO: find cleaner way to sync outside Angular change detection ?
87
+
list.forEach(n=>{
88
+
constitem=this._items.find(i=>i.id===n.id);
89
+
if(item)Utils.copyPos(item,n);
90
+
})
91
+
,0);
92
+
}
93
+
87
94
/**
88
95
* CRUD operations
89
96
*/
90
97
publicadd(){
98
+
// new array doesn't seem required. Angular seem to detect changes to content...
Copy file name to clipboardExpand all lines: demo/index.html
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,14 @@ <h1>Demos</h1>
32
32
<li><ahref="web2.html">Website demo 2</a></li>
33
33
</ul>
34
34
<h1>Angular src Demos</h1>
35
-
<p>these are complete Angular projects with multiple options. use `yarn` and `yarn start` in demo/angular sub-project to build</p>
36
-
<ul>
35
+
<p>these are complete Angular projects with multiple options. use `yarn` and `yarn start` in demo/angular sub-project to run them</p>
36
+
<p>You can find the complete source at <ahref="https://github.com/gridstack/gridstack.js/tree/master/demo/angular" target="_blank">Angular Demo</a></p>
0 commit comments