0

My templates bootstrap contain JS, as they are called JS is not executed, you have an idea please.

This is my Index.html

<body ng-app>
    <ng-include src="'sidebar.html'"></ng-include>
    <ng-include src="'navbar.html'"></ng-include>
</body>

My navbar.html

<header class="navbar navbar-inverse" role="banner">
            <button type="button" id="menu-toggler">
                ...
            </button>

in my template library there are - theme.js

$("#menu-toggler").click(function (e) {
    $("body").toggleClass("menu");
    e.stopPropagation();
  });

when in Body element there are 'menu' class, CSS show a sidebar

who know why it doesn't show?? (Demo jsfiddle)

Silvio Troia
  • 1,439
  • 19
  • 36

1 Answers1

1

Do NOT use Angular like you would use jQuery; add ng-class to the <body>, add ng-click to your button and handle the event from Angular:

<body ng-class="{'menu': bodyIsMenu} ng-controller="Ctrl">
    ...
    <button ng-click="toggle()">...</button>
    ...
</body>

Note I placed the controller in the body, so as for toggle() and bodyIsMenu to be in the same scope. The JS:

function Ctrl($scope) {
    $scope.bodyIsMenu = false;

    $scope.toggle = function() {
        $scope.bodyIsMenu = !$scope.bodyIsMenu;
    };
}

Also a very interesting read here.

Community
  • 1
  • 1
Nikos Paraskevopoulos
  • 39,514
  • 12
  • 85
  • 90