Getting reference error of jQuery after adding jQuery DateTimePicker (not official) in angular project











up vote
1
down vote

favorite












In my angular project, when I didn't add jQuery DateTimePicker Clean jQuery DateTimePicker



jQuery was working fine with my angular project. Here's how I have defined it in my project.



lib.ts



declare var jQuery: any;

window['jQuery'] = require('jquery');
window['$'] = window['jQuery'];


and using it in any component like this



account.component.ts



import { Component, AfterViewInit } from '@angular/core'

declare var $ : any;

@Component({
selector: 'app-account',
templateUrl: './account.component.html',
styleUrls: ['./account.component.css']
})

export class AccountComponent implements AfterViewInit {

constructor(){
}

ngAfterViewInit(){
$(".submitBtn").click(() => {
$(this).css("color", "red");
});
}

}


And I am not getting any error on the console. But when did I add jQuery DateTimePicker ( link on the above ) into my project.



package.json



"dependencies": {
// Other Dependencies //

"jquery-datetimepicker": "^2.5.20",

// Other Dependencies //
}


defined it into scripts as part of angular-cli.json



"styles": [
"styles.css",
"../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.min.css"
],
"scripts": [
"../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.js",
],


It started giving me error on the console.



Uncaught ReferenceError: jQuery is not defined
at scripts.bundle.js:2661
at scripts.bundle.js:2663


In my template, jQuery DateTimePicker is working absolutely fine when we do



$('#demo').datetimepicker({inline:true,});



But that Reference error is still there on my console , it appears whenever I hit refresh or change any thing inside IDE.










share|improve this question


























    up vote
    1
    down vote

    favorite












    In my angular project, when I didn't add jQuery DateTimePicker Clean jQuery DateTimePicker



    jQuery was working fine with my angular project. Here's how I have defined it in my project.



    lib.ts



    declare var jQuery: any;

    window['jQuery'] = require('jquery');
    window['$'] = window['jQuery'];


    and using it in any component like this



    account.component.ts



    import { Component, AfterViewInit } from '@angular/core'

    declare var $ : any;

    @Component({
    selector: 'app-account',
    templateUrl: './account.component.html',
    styleUrls: ['./account.component.css']
    })

    export class AccountComponent implements AfterViewInit {

    constructor(){
    }

    ngAfterViewInit(){
    $(".submitBtn").click(() => {
    $(this).css("color", "red");
    });
    }

    }


    And I am not getting any error on the console. But when did I add jQuery DateTimePicker ( link on the above ) into my project.



    package.json



    "dependencies": {
    // Other Dependencies //

    "jquery-datetimepicker": "^2.5.20",

    // Other Dependencies //
    }


    defined it into scripts as part of angular-cli.json



    "styles": [
    "styles.css",
    "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.min.css"
    ],
    "scripts": [
    "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.js",
    ],


    It started giving me error on the console.



    Uncaught ReferenceError: jQuery is not defined
    at scripts.bundle.js:2661
    at scripts.bundle.js:2663


    In my template, jQuery DateTimePicker is working absolutely fine when we do



    $('#demo').datetimepicker({inline:true,});



    But that Reference error is still there on my console , it appears whenever I hit refresh or change any thing inside IDE.










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      In my angular project, when I didn't add jQuery DateTimePicker Clean jQuery DateTimePicker



      jQuery was working fine with my angular project. Here's how I have defined it in my project.



      lib.ts



      declare var jQuery: any;

      window['jQuery'] = require('jquery');
      window['$'] = window['jQuery'];


      and using it in any component like this



      account.component.ts



      import { Component, AfterViewInit } from '@angular/core'

      declare var $ : any;

      @Component({
      selector: 'app-account',
      templateUrl: './account.component.html',
      styleUrls: ['./account.component.css']
      })

      export class AccountComponent implements AfterViewInit {

      constructor(){
      }

      ngAfterViewInit(){
      $(".submitBtn").click(() => {
      $(this).css("color", "red");
      });
      }

      }


      And I am not getting any error on the console. But when did I add jQuery DateTimePicker ( link on the above ) into my project.



      package.json



      "dependencies": {
      // Other Dependencies //

      "jquery-datetimepicker": "^2.5.20",

      // Other Dependencies //
      }


      defined it into scripts as part of angular-cli.json



      "styles": [
      "styles.css",
      "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.min.css"
      ],
      "scripts": [
      "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.js",
      ],


      It started giving me error on the console.



      Uncaught ReferenceError: jQuery is not defined
      at scripts.bundle.js:2661
      at scripts.bundle.js:2663


      In my template, jQuery DateTimePicker is working absolutely fine when we do



      $('#demo').datetimepicker({inline:true,});



      But that Reference error is still there on my console , it appears whenever I hit refresh or change any thing inside IDE.










      share|improve this question













      In my angular project, when I didn't add jQuery DateTimePicker Clean jQuery DateTimePicker



      jQuery was working fine with my angular project. Here's how I have defined it in my project.



      lib.ts



      declare var jQuery: any;

      window['jQuery'] = require('jquery');
      window['$'] = window['jQuery'];


      and using it in any component like this



      account.component.ts



      import { Component, AfterViewInit } from '@angular/core'

      declare var $ : any;

      @Component({
      selector: 'app-account',
      templateUrl: './account.component.html',
      styleUrls: ['./account.component.css']
      })

      export class AccountComponent implements AfterViewInit {

      constructor(){
      }

      ngAfterViewInit(){
      $(".submitBtn").click(() => {
      $(this).css("color", "red");
      });
      }

      }


      And I am not getting any error on the console. But when did I add jQuery DateTimePicker ( link on the above ) into my project.



      package.json



      "dependencies": {
      // Other Dependencies //

      "jquery-datetimepicker": "^2.5.20",

      // Other Dependencies //
      }


      defined it into scripts as part of angular-cli.json



      "styles": [
      "styles.css",
      "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.min.css"
      ],
      "scripts": [
      "../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.js",
      ],


      It started giving me error on the console.



      Uncaught ReferenceError: jQuery is not defined
      at scripts.bundle.js:2661
      at scripts.bundle.js:2663


      In my template, jQuery DateTimePicker is working absolutely fine when we do



      $('#demo').datetimepicker({inline:true,});



      But that Reference error is still there on my console , it appears whenever I hit refresh or change any thing inside IDE.







      jquery angular






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 7:09









      Rishikesh Dehariya

      455




      455
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          This will help you :



          1)Install Jquery Plugin For angular



          npm install jquery --save



          2)Now in your app.module.ts add



          import * as $ from "jquery"






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369840%2fgetting-reference-error-of-jquery-after-adding-jquery-datetimepicker-not-offici%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            This will help you :



            1)Install Jquery Plugin For angular



            npm install jquery --save



            2)Now in your app.module.ts add



            import * as $ from "jquery"






            share|improve this answer

























              up vote
              2
              down vote













              This will help you :



              1)Install Jquery Plugin For angular



              npm install jquery --save



              2)Now in your app.module.ts add



              import * as $ from "jquery"






              share|improve this answer























                up vote
                2
                down vote










                up vote
                2
                down vote









                This will help you :



                1)Install Jquery Plugin For angular



                npm install jquery --save



                2)Now in your app.module.ts add



                import * as $ from "jquery"






                share|improve this answer












                This will help you :



                1)Install Jquery Plugin For angular



                npm install jquery --save



                2)Now in your app.module.ts add



                import * as $ from "jquery"







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 at 7:17









                sonal.paghdal

                1295




                1295






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369840%2fgetting-reference-error-of-jquery-after-adding-jquery-datetimepicker-not-offici%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy