-2
I am developing a component in Angular version 8 and in the html part of the component I am using the following navbar: https://bootsnipp.com/snippets/kl8Q3 but when I try to embed javascript in my component I can’t implement it in typescript.
After doing research on how to "convert" js to typescrip I found obsolete examples that didn’t work. I have little knowledge in Angular and I have no idea how to proceed with the solution of this problem. Below is the code that I intend to use:
 $(document).ready(function() {
            $(".menu-icon").on("click", function() {
                  $("nav ul").toggleClass("showing");
            });
      });
      // Scrolling Effect
      $(window).on("scroll", function() {
            if($(window).scrollTop()) {
                  $('nav').addClass('black');
            }
            else {
                  $('nav').removeClass('black');
            }
      })
What error are you getting ? No need to install jquery type lib ?
npm i -D @types/jquery– Colasanto
I get no error. This javascript code does not work in my angular application. You know where it should be placed?
– piresthiago10
You can try to put it on
ngOnInit()of its navbar component.– Colasanto