Question: I want to add a class for parent element by clicking the child button

 some text.....

 title text

 +

```
    <div class="collapseBox border mb-2" [ngClass]="{active: active2}">
            <div class="collapse_inner">
                    some text....
            </div>
            <div class="header py-2 px-2">
                    <h5 class="mb-0">title text</h5>
            </div>
            <button (click)="active1!= active1">+</button>
    </div>

```

I want to collapse the targeted div by clicking the button, I am trying to add active class to parent div when clicking button

Answer: 
Make your ngClass a ternary and define your current class in ngClass.

```
<div [ngClass]="active ? 'collapseBox border mb-2 active' : 'collapseBox border mb-2'">

```

Also your click assignment logic is not correct, try 

`(click)="active = !active"`
I m doing the click function wrongly it should be. (click)="active1 = !active1"