angular onclick toggle class

// component.ts
toggleClass: boolean = false;

// component.html
<button (click)="toggleClass = !toggleClass" [ngClass]="{ 'button--grey': !toggleClass }">
  Confirm
</button>

3.67
3
IllusiveBrian 18110 points

                                    $scope.toggle = false;


&lt;button id=&quot;btn&quot; ng-click=&quot;toggle = !toggle&quot; ng-class=&quot;{'red' : toggle}&quot;&gt;Change Class&lt;/button&gt;

3.67 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to toggle class on click on different element in angular on click on body toggle class angular toggle classes by click method angular toggle class click angular toogle class clicked item angular ng-class toggle on click angular 9 toggle class on click angular toggle class onclick angular toggle div class on click angular toggle class on click ngclass on click button toggle use ngclass use button toggle in angular angular button toggle class toggle class with button click angular angular on click toggle class toggle class on click angular angular click toggle class angular on click toggle angular inline click toggle class toggle on click angular click toggle class angular angular toggle css class on click angular 10 toggle class onclick angular toggle on click for ngClass toggle angular give button a class when its clicked angular give a button a css class if its clicked angular get class and then click button using classname with click function how to write in ts angular 6 angular toggle class angular change class on click angular onclick update class toggle css class angular angular show class on click ng class if clicked toggle class on detail in angular angular use button to toggle class on element click event for specific css class in angular 6 angular onclick toggle class angular custom toggle button example angular bootstrap toggle button angular ng-click toggle class toggle class on click button angular ng click toggle class angular 8 toggle class on click example angularjs toggle class on click
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source