A
A
Artem Shchurin2017-02-20 11:27:32
Angular
Artem Shchurin, 2017-02-20 11:27:32

Angular 2. How to select markup inside ng-content?

I am making a universal component that will catch drag-n-drop files
I want to hang event processing on the content that will be inside

ng-content

Component Implementation
@Component({
    selector: 'drop-area',
    template: '<ng-content></ng-content>'
})

export class DropAreaComponent
{
    @Output('file') fileEvent: EventEmitter<File> = new EventEmitter<File>();
    @Output('hover-drag') hoverEvent: EventEmitter<boolean> = new EventEmitter<boolean>();

    constructor() {
    }
}

How to use
<drop-area file="fileChange()" hover-drag="dragArea()">
    <div id="target"></div>
</drop-area>

How to get div with id target in drop-area component?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2017-02-20
@schurin

learnangular2.com/viewChild

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question