I have some <select class='select'>
's in a @Component.
I'm following a template which styles every select with a third-party library called Select2. The HTML + jQuery + Select2 code is:
$( document ).ready(function() {
$('.select').select2();
});
I was wondering if it would be a good idea to create a directive for doing this, so I tried:
import {Directive, ElementRef} from '@angular/core';
@Directive({
selector: '[simple-dropdown]'
})
export class SimpleDropdownDirective {
constructor(el: ElementRef) {
$(el.nativeElement).select2();
}
}
But I'm getting error on the select2()
method. Since it's a third-party library I don't think I can install it as I've done with jQuery.
What would you suggest?