Open saitho opened 6 years ago
Hi!, I've been trying unsucessfully to implement this aswell, add new shapes dinamically to a stage. I've tried @saithos aproximation and adding them directly to the layer as if I was using the JavaScript directly but no luck :( , is this task possible with the current library?
I tried this with queryList updates a while ago (when I was totally new to angular 4). I dont use ng2-konva right now, I have an own implementation which uses injectors alot, which uses the fact that each parent component can be injected to childs. The child then can operate on the parent. I will think about whether to continue with my implementation or ng2-konva in the next days. In case Ill go with ng2-konva, you might find the desired feature soon :-)
Had the same issue, gave up and now I'm recreating the whole scene at every change, using *ngIf and ChangeDetectorRef
Are there any updates on this? I am facing the same issue adding shapes in click event.
Is there any update yet, I also have the same requirement of adding stage, layers, groups and shapes dynamically ?
In the latest version the above example seems to work fine. Just change the 'rxjs/Observable' -> 'rxjs' and add 'of' as import (of rxjs). Code: ` import { Component, OnInit, ViewChild } from '@angular/core'; import { BehaviorSubject, Observable,of } from 'rxjs'; import { KonvaComponent } from 'ng2-konva';
@Component({
selector: 'star-example',
template:
<button (click)="addStarBtn()">Adda
<div ngFor="let item of list">test
The mentioned example does not add star on button click. It updates the array but does not add it to the layer. After inspecting the stage and layer, the number of children in the layer remain unchanged
Any updates ? The issue still continues .
guys maybe you just need to add stage.batchDraw() after u add the figure dinamically in order to update the layer, this worked for me
Any updates ? The issue still there . Kindly share demo @ stackblitz
The mentioned example does not add star on button click. It updates the array but does not add it to the layer. After inspecting the stage and layer, the number of children in the layer remain unchanged
Any breakthrough?
Any updates here ?
I'm trying to add objects to my Konva stage by clicking on buttons. I adjusted the star example but I can't get it to work. Is there a way to do that? :)
https://gist.github.com/saitho/a244927f4dc9ea73b50eb8f86a833047