-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change and update the created list in an HTML template? #27
Comments
Can I give this is a kick please? Same problem - the ko-image doesn't seem to actually render an image. Could you (the project owner) provide an example of how to have an array of Image configs, and have them render on-screen please? Regards, |
HI, To resolve this issue, modify the ngAfterContentInit function in the stage.component.ts and core-shape.component.ts files. The following code solves the problem, but each time you change it, it deletes all the nodes and then re-creates them. ngAfterContentInit() {
this.shapes.forEach((item: CoreShape) => {
this._stage.add(item.getStage());
updatePicture(this._stage);
});
// subscribe changes
this.shapes.changes.subscribe(() =>{
const stage = this.getStage();
if (stage) {
// old nodes
const nodes = this._stage.getChildren();
// remove all nodes...
nodes.forEach(node => {
node.remove();
node.destroy();
});
// create all nodes
this.shapes.forEach((item: CoreShape) => {
this._stage.add(item.getStage());
updatePicture(this._stage);
});
}
});
} I use the code below, here it only removes deleted items and creates new ones. ngAfterContentInit() {
this.shapes.forEach((item: CoreShape) => {
this._stage.add(item.getStage());
updatePicture(this._stage);
});
// subscribe changes
this.shapes.changes.subscribe(() =>{
const stage = this.getStage();
if (stage) {
const nodes = this._stage.getChildren();
// filter deleted items
const snodes = nodes.filter(node => !this.shapes.some(s => s.getStage()._id === node._id));
snodes.forEach(node => {
node.remove();
node.destroy();
});
// filter new items
const sh = this.shapes.filter(s => !nodes.some(n => n._id === s.getStage()._id));
sh.forEach((item: CoreShape) => {
this._stage.add(item.getStage());
updatePicture(this._stage);
});
}
});
} If we move a shape between two layers, we use the moveTo function before modifying the Observable array. This is important so that the remove and add parts do not run in this case! |
Hello.
I created in html-template list
In the list I can change the configs, but I can not increase the list or decrease.
The list in the code grows, but not on the canvas
The text was updated successfully, but these errors were encountered: