Search code examples
angulardaterangepicker

How to use daterangepicker package with Angular?


I was trying to use daterangepicker in an angular project and getting the following errors. Can someone please help me out how to get it working? Thanks!. Here is the stack blitz link for the same. Stackblitz


Solution

  • he package you show need jQuery and moment. Personally I think that is not a good idea use jQuery and Angular, but if you want to include see, e.g. this link

    npm install jquery — save
    

    And edit your angular.json adding in scripts

          "scripts": [
              "node_modules/jquery/dist/jquery.min.js"
            ]
    

    And use

    import $ from 'jquery';
    

    In your component

    NOTE: use ngOnInit, not the constructor

    NOTE2: don't forget include the daterangepicker.css in your style

    See your forked stackblitz