Not able to remove nested array element in array using Javascript

Discussão em 'Angular' iniciado por Samir Sheikh, Novembro 21, 2024.

  1. Samir Sheikh

    Samir Sheikh Guest

    In the below the screen shot , mentioned nested element as child array.

    [​IMG]

    I wanted to remove child array element , I used below the script but it's only remove first element.

    removeChildWidget(parIndex:number,index:number){
    if (parIndex >= 0) {
    const widgetNumber = this.dashRightWidget[parIndex]?.widgetNumber;
    const widgeDashtNumber = this.dashboardWidgets[parIndex]?.widgetNumber;

    this.widgets.forEach((widget) => {
    if (widget.widgetNumber == widgeDashtNumber) {

    console.log("wid",widget.child[index])
    if (index >= 0) widget.child.splice(index, 1)
    console.log("wid",widget)
    }
    });
    console.log('final output', this.dashboardWidgets)

    }
    }

    Continue reading...

Compartilhe esta Página