In my task i use http://mdbootstrap.com/javascript/date-picker
How I can use date-picker in angular 2 component, i must add this code in jquery to typescript component $('.datepicker').pickadate();
in my component.
my_component.ts
import { Component, OnInit, ElementRef } from '@angular/core';
declare var $: any;
@Component({
// selector: 'clients',
templateUrl: './src/client/app/views/clients.html',
})
export class ClientsModel implements OnInit {
constructor(private _elmRef: ElementRef) {}
/* this code not work*/
ngOnInit() {
$(this._elmRef.nativeElement)
.find('#date-picker-example')
.on('click', function(){
$('#date-picker-example').pickadate();
});
}
}
my_component.html
<div class="md-form col-xl-2 col-lg-3 col-md-4 col-sm-6 col-xs-12" style="margin-top: 1%;">
<input type="text" id="date-picker-example" class="form-control datepicker">
<label for="date-picker-example">Date begin</label>
</div>