简体   繁体   中英

How to get jquery ui date picker working with angular2?

How to get jquery ui date picker working with angular2?

I'm using angular2 and typescript with html5.

I'm trying to add the jquery ui datepicker.

I have all the librarys and the css added but the datepicker jquery code is wiring up to the html.

lib: https://jqueryui.com/datepicker/

Heres my code:

  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>

  <p>Date: <input type="text" id="datepicker"></p>

I've tried putting this in my component : $( "#datepicker" ).datepicker(); But I just get errors.

any ideas?

I get this error when I add the project to mine:

在此输入图像描述

Well there are already many datepicker libraries available for the angular2. few of them i have posted below:

but yes obviously everyone need stylish datepicker for our project me too want same so i according to need i have created one datepicker using bootflat framework for styling. you can refer here..

https://github.com/MrPardeep/Angular2-DatePicker

hope this may help you !

在此输入图像描述

PrimeNG also provides a component for DatePicker. Live demo;

http://www.primefaces.org/primeng/#/calendar

Here is another one with many configurations, live demo:
https://vlio20.github.io/ng2-date-picker/

See this question as a answer of how to use jQuery UI plugins in your app Whats the best way to use jquery widgets inside angular 2?

This example uses ElementRef but you could also use ViewChild

:-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM