Cannot read property 'trim' of undefined at EditQuestionDialogComponent_Template

Проект на Angular Имеется строковая переменная question, определенная в классе:

export class QuestionModel {
  id: string;
  question: string;

  constructor(id: string, question: string) {
    this.id = id;
    this.question = question;
  }
}

в html файле пред тем как очистить поле делаю проверку, что эта переменная не пустая

<button
  *ngIf="quest.question.trim().length > 0"
  class="clear-icon"
  mat-button matSuffix mat-icon-button aria-label="Clear"
  (click)="question= ''"
>

В консоле браузера получаю ошибку:

ERROR TypeError: Cannot read property 'trim' of undefined at EditQuestionDialogComponent_Template

Что не так?


Ответы (0 шт):