I am trying to use this datetime picker within an angular 2.0 component.
Here is my index.html
<head>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
</head>
Here is my component file
import { Component, OnInit } from '@angular/core';
@Component({
selector : 'datepicker-display',
template: `
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
`
})
export class DatePickerDisplayComponent implement OnInit {
ngOnInit(): void {
$('#datetimepicker1').datetimepicker(); // don't want to initialize DP until component is initialized
}
}
When I go to compile the typescript, I get the error
app/components/datepicker-display.component.ts(28,9): error TS2304: Cannot find name '$'.
This makes sense to me, because I haven't explictitly declared "$" to exist in this component file. However, I am now unsure how to use JQuery inside one of my components. If I remember correctly, what I am trying to do in NG1 would have worked... I could have just included the jquery source in my index.html and used "$" normally.
What is the proper way to do this in NG2? For a bit of background, I am using gradle to build my project, with the node/npm plugin.