TypeError:无法读取nativescript中未定义的属性'cartesianChart'

时间:2018-02-25 06:09:13

标签: nativescript angular2-nativescript nativescript-telerik-ui

我是原版的新内容。我尝试学习nativescript中的图表,但它给出了“TypeError:无法读取属性'cartesianChart'的未定义”错误。

home.componet.html

<RadCartesianChart tkExampleTitle tkToggleNavButton>
<CategoricalAxis tkCartesianHorizontalAxis></CategoricalAxis>
<LinearAxis tkCartesianVerticalAxis></LinearAxis>
<LineSeries tkCartesianSeries [items]="categoricalSource" categoryProperty="Country" valueProperty="Amount"></LineSeries>

home.component.ts

    import { Component, OnInit,ViewChild,AfterViewInit ,ElementRef} from '@angular/core';
import { WebView, LoadEventData } from "ui/web-view";
import { ObservableArray } from "tns-core-modules/data/observable-array";
import{DataService} from "../data.service"
import{Country} from "../country"

@Component({
  moduleId: module.id,
  selector: 'app-home',
  providers: [DataService],
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  private _categoricalSource: ObservableArray<Country>;

  constructor(private _dataService: DataService) { }

  get categoricalSource(): ObservableArray<Country> {
      return this._categoricalSource;
  }

  ngOnInit() {
      this._categoricalSource = new ObservableArray(this._dataService.getCategoricalSource());
  }

}

1 个答案:

答案 0 :(得分:4)

我遇到了同样的问题并通过删除Android平台并再次添加它来解决它。

tns platform remove android
tns platform add android