agoncal-sample-angular icon indicating copy to clipboard operation
agoncal-sample-angular copied to clipboard

Collapsible Bootstrap sidebar menu

Open agoncal opened this issue 6 years ago • 4 comments

In this great article the author shows many different ways to get a collapsible sidebar menu. I've tried implementing it, but it always comes back to a

ReferenceError: $ is not defined

I've tried defining JQuery in several ways, adding the @types/jquery dependencies... I can't make it work. And the little bit of JavaScript needed to collapse the menu doesn't work :

$(document).ready(function () {

    $('#sidebarCollapse').on('click', function () {
        $('#sidebar').toggleClass('active');
    });

});

agoncal avatar Aug 11 '18 16:08 agoncal

Check out Angular Material

lazycuh avatar Aug 14 '18 06:08 lazycuh

I would study this article by https://toddmotto.com/ng-class-angular-classes. You don't need jQuery. <div [class.active]="condition"></div>

GoNode5 avatar Aug 14 '18 06:08 GoNode5

Definitely do this the Angular way, there is no need to mix-in jQuery for this. Angular is fully capable. If you must use jQuery, you have to tell it how import * as $ from "jquery";

jwill124 avatar Jul 16 '19 19:07 jwill124

as @jwill124 said. using jQuery on angular apps in not considered to be good practice.

devpato avatar Sep 26 '19 04:09 devpato