i am working in angular 2 project and want to integrate daterangepicker.js library to pop up date range picker. here link to library in case you do not hear about it before http://www.daterangepicker.com/
htmlcode:
<input type="text" placeholder="Start - End" class="oa-search-height padd" name="daterange" > </div>
and inside my index.html
<script src="./assets/js/daterangepicker.min.js" > </script>
<link rel="stylesheet" type="text/css" href ="./assets/css/daterangepicker-bs3.min.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[name="daterange"]').daterangepicker();
});
</script>
also i create directive
import { Directive, ElementRef, Input, Renderer } from '@angular/Core';
declare var jQuery: any;
@Directive({
selector: '[date-range]',
host: {
'(keyup)': 'dateRangePicker()'
}
})
export class DateRangeDirective {
private element: HTMLElement;
private renderer: Renderer;
constructor(element: ElementRef, renderer: Renderer) {
this.element = element.nativeElement;
this.renderer = renderer;
}
@Input('date-range');
dateRangePicker(){
jQuery(this.element).daterangepicker();
}
}
Couple of samples available, refer these options-
https://github.com/onehungrymind/ng2-bootstrap-daterangepicker
https://github.com/simpulton/ng2-daterangepicker
See if this helps.
EDIT: