typescript - input değişkeni ile angular hostbinding


CSS stillerini duruma bağlı olarak ayarlamaya çalışıyorum; değişiklik true olduğunda arka plan kırmızı, değişiklik false olduğunda arka plan siyah olsun. Ama hostbinding'e bunu değişiklik bayrağını kontrol ederek nasıl bildireceğimi bilmiyorum. Örnek kod şöyle:

 import { Component, HostBinding } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  title: string;
  change: boolean;
  @HostBinding('class.someChange') isChanged() {
    this.change = true;
    return this.change;
  }

  constructor() {
    this.title = 'Tour of Heroes';
  }
}

ve HTML dosyası için şöyle:

<h1>{{title}}</h1>

<nav>
  <a routerLink = "/dashboard"> Dashboard </a>
  <a routerLink = "/heroes"> Heroes </a>
</nav>
<router-outlet></router-outlet>
<app-messages></app-messages>

CSS dosyası aşağıdadır:

:host {
  width: 100%;
  height: 100%;
  display: block;
  background-color: rgb(0, 255, 149);
  padding: 20px;
  color: #ffffff;
  text-align: center;
  font-weight: bold;
  &.someChange {
    background-color: red;
  }
}