$ is not defined with Angular build

$ is not defined with Angular build

asheikhasheikh Posts: 6Questions: 3Answers: 0

I used the documentation https://l-lin.github.io/angular-datatables/#/getting-started to implement the datatable in my angular 8 application. It works fine during development but stops working when I create a production build giving the error $ is not defined. I have been looking over the internet for a solution but nothing worked. Please help me with this.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    You would get that if you're not including the jQuery source file.

    Colin

  • asheikhasheikh Posts: 6Questions: 3Answers: 0

    Also, If this was the case, then it should not work during development either.

  • asheikhasheikh Posts: 6Questions: 3Answers: 0

    @colin I am including jquery file. Let me post my angular.json scripts

    "scripts": [
    "node_modules/popper.js/dist/umd/popper.js",
    "node_modules/tooltip.js/dist/umd/tooltip.min.js",
    "node_modules/perfect-scrollbar/dist/perfect-scrollbar.js",
    "node_modules/jquery/dist/jquery.js",
    "node_modules/datatables.net/js/jquery.dataTables.js",
    "node_modules/jszip/dist/jszip.js",
    "node_modules/datatables.net-buttons/js/dataTables.buttons.js",
    "node_modules/datatables.net-buttons/js/buttons.colVis.js",
    "node_modules/datatables.net-buttons/js/buttons.flash.js",
    "node_modules/datatables.net-buttons/js/buttons.html5.js",
    "node_modules/datatables.net-buttons/js/buttons.print.js"
    ],

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922
    edited April 2020

    Wonder if this SO thread might help or this?

    Kevin

This discussion has been closed.