2

I am trying to change the following codes in javascript to typescript.I am unable to do that please help.

$(function () {
    $(".navigation_icon").click(function () {
        $(".navigation").toggleClass('navigation-open');
    });
});
1
  • Please let us know what is your problem exactly. Commented Jul 18, 2020 at 3:48

1 Answer 1

3

If you are looking for an angular solution please provide more detail. Here is a solution to your question. First of all, In your ts file, you should define a boolean to keep the state of navigation, then you define a function to toggle the navigation state.

IsNavigationOpen : boolean = true;

navigationToggle(): void {
  IsNavigationOpen = !IsNavigationOpen;
}

then you can define a button to use the function and the last part is a condition to set a CSS class for your navigation bar.

<button onclick="navigationToggle" class="navigation_icon">

<div class="navigation {{IsNavigationOpen ? 'navigation-open' : 'navigation-closed'}}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.