title: How to change/toggle class of a div on click a button in angular 6
body: <p>Here I have a <strong>div</strong> having class name is <code>old</code>. I have a button also <strong>onchange/toggle</strong> of the button I need to change the <strong>div's</strong> class name to <code>new</code>.Again click on to button I need to change the class of div to <code></code>.so on.. in angular 6. Here is the code below, </p>
  
  <p>Actually I new in angular 6 can anyone please help me.</p>
  
  <h2>app.component.html</h2>
  
  <pre><code>&lt;button (click)="change()"&gt;change&lt;/button&gt;
  &lt;div class="old"&gt;
    Hello
  &lt;/div&gt;
  </code></pre>
  
  <h2>app.component.ts</h2>
  
  <pre><code>import { Component } from '@angular/core';
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
  
    change(){
      alert('change');
    }
  
    ngOnInit() {
  
  }
  }
  </code></pre>