import { Component } from '@angular/core' ; import { CdkDragDrop , moveItemInArray , transferArrayItem , CdkDrag } from '@angular/cdk/drag-drop' ; title @ Component ( { selector : 'cdk-drag-drop-enter-predicate-example' , templateUrl : 'cdk-drag-drop-enter-predicate-example.html' , styleUrls : [ 'cdk-drag-drop-enter-predicate-example.css' ] , } ) export class CdkDragDropEnterPredicateExample { all = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ; even = [ 10 ] ; drop ( event ) { if ( event . previousContainer === event . container ) { moveItemInArray ( event . container . data , event . previousIndex , event . currentIndex ) ; } else { transferArrayItem ( event . previousContainer . data , event . container . data , event . previousIndex , event . currentIndex ) ; } } /** Predicate function that only allows even numbers to be dropped into a list. */ evenPredicate ( item ) { return item . data % 2 === 0 ; } /** Predicate function that doesn't allow items to be dropped into a list. */ noReturnPredicate ( ) { return false ; } }