Search code examples
angularangular-cdkangular-cdk-drag-dropangular13

angular cdk drag & drop Directly by click event Instead of dragging


angular cdk drag & drop : how drag item to done List Directly by click event Instead of dragging For example on the 'jotform' site , when we click on each item in Left section Items, it performs operations automatically and drag it to main list


Solution

  • That's should be an easy case, if I got it well; you wanna move an Item from a list to another when the user clicks on a button, right?

    moveItem(previousList, currentList, previousIndex) {
        // let assume that the user will move it as last element
        let currentIndex = this.currentList.length;
        transferArrayItem(previousList,
            currentList,
            previousIndex,
            currentIndex);
    }