Свойство «подписка» не имеет инициализатора и определенно не назначено в конструкторе

#angular10

Вопрос:

В моем приложении Angular в файле компонента. Пожалуйста, найдите скриншот для html-файла компонента и файла ts. Можете ли вы сказать мне, в чем моя ошибка как в подписке, так и в чартопции.

 import { Component, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { ChartserviceService } from '../service/chartservice.service';
import { LineChartModel} from '../model/chartmodel.model';
import { EChartsOption } from 'echarts';

@Component({
  selector: 'app-linechart',
  templateUrl: './linechart.component.html',
  styleUrls: ['./linechart.component.css']
})
export class LinechartComponent implements OnInit {

  subscription: Subscription;
  chartOption: EChartsOption;
  //chartModel = new LineChartModel();


  constructor(public chartService : ChartserviceService) { }

  ngOnInit(): void {
    this.subscription = this.chartService.getChartData().subscribe(data => {
      this.basicLineChart(data);
    })
  }

  basicLineChart(echartData : LineChartModel[]){
    this.chartOption = {
      tooltip : {
        show : true
      },
      backgroundColor : 'transparent',
      xAxis: {
        type: 'category',
        data: echartData.map(m=>({
          value : m.name
        }))
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: echartData.map(m=>({
          value : m.value
        })),
        type: 'line'
    }]
    }
  }

}
 

Скриншот файла TS компонента.

введите описание изображения здесь

Комментарии:

1. Значит, ваше приложение не работает? вы добавили ngOnDestroy(): void { this._subscription.unsubscribe(); } в свой компонент ?