2

I have 3 buttons in a row. I want to set active class on clicked button only but problem is when i clicked another button after one button so it is setting active class on all buttons.

Set active class is not working correctly. All buttons get active class when clicked. If i will click on 2 buttons it will set active class on both button when clicked.

Here is my code at stackblitz

StackBlitz Code

i want to set active class only on clicked button at a time not on all the buttons.

2 Answers 2

3

I think that you can do this more easy, with angular dom features.

You can show here:

https://stackblitz.com/edit/angular-s8suc8?file=src/app/app.component.ts

it is a sample that I think that you want, but I think that you can do it better:

https://stackblitz.com/edit/angular-vmzijo?file=src/app/app.module.ts

Sign up to request clarification or add additional context in comments.

Comments

0

as far as i can understand you need to toggle on active and inactive status:

This is the new plunker , have a look if it solves the issue:

https://stackblitz.com/edit/angular-fzxhkv?file=src/app/app.component.ts

I have removed event.srcElement.classList.add('phase-active') which was responsible for applying phase-active on every button

2 Comments

it is still not working correctly. Please see carefully on your result. If you will click in button "P-I" so button gets red but when you will click on button "P-II" after click on "P-I" so both buttons will get active class.
Now I got your point ...I have updated the stackblitz; solving the issue

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.