O'Reilly logo

Mastering Angular Components by Gion Kunz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a drop target directive

Drop zones will act as containers where draggable elements can be dropped. For this, we'll create a new draggable drop zone directive. Let's use the Angular CLI to create the directive:

ng generate directive --spec false draggable/draggable-drop-zone

Let's open the directive file, located in src/app/draggable/draggable-drop-zone.directive.ts, and add the following code:

import {Directive, EventEmitter, HostBinding, HostListener, Input, Output} from '@angular/core';import {DraggableType} from '../model';@Directive({  selector: '[macDraggableDropZone]'})export class DraggableDropZoneDirective {  @Input() dropAcceptType: DraggableType;  @Output() outDropDraggable = new EventEmitter<any>(); @HostBinding('class.over') ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required