Skip to content

ngOnInit() called twice in Widget component #33

Open
@anvial

Description

@anvial

Hello,

I use standard widget component template. See next:

@Component({
  selector: 'line-widget',
  templateUrl: './line-widget.component.html',
  styleUrls: ['./line-widget.component.css'],
  providers: [{provide: WidgetComponent, useExisting: forwardReference}]

})
export class LineWidgetComponent extends WidgetComponent implements OnInit {
  @ViewChild(WidgetHandleDirective) protected _handle: WidgetHandleDirective;

  @Input() public size: number[] = [2, 2];
  @Input() public widgetId: string;
  @Output() onClose = new EventEmitter<any>();

  // somecode

  constructor(
    ngEl: ElementRef,
    renderer: Renderer2
  ) {
    super(ngEl, renderer);
  }

  ngOnInit() {
    super.ngOnInit();
    console.warn('line chart');
  }

  closeWidget() {
    this.onClose.emit(this.widgetId);
  }

}

The problem is when I'm adding this widget to dashboard – the ngOnInit() method called twice.

Any suggestions?
Thank You.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions