简体   繁体   中英

how to fix 'Property 'dials' does not exist on type 'Object' in typeScript

import { Component, OnInit } from '@angular/core';
import { DashboardService } from 'src/app/provider/dashboard.service';

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

  revenueTargetProgress: Object;
  dials: object;   
  Guage = this.TotalRevenue;

  constructor(private api: DashboardService) { 

    this.revenueTargetProgress = {
  chart: {
    caption: "Revenue Target Progress",
    lowerLimit: "0",
    upperLimit: "100000000",
    showValue: "1",
    numberPrefix: "₹ ",
    theme: "fusion",
    showToolTip: "0"
  },
  // Chart Data
  colorRange: {
    color: [
      {
        minValue: "0",
        maxValue: "30000000",
        code: "#F2726F"
      },
      {
        minValue: "30000000",
        maxValue: "80000000",
        code: "#FFC533"
      },
      {
        minValue: "80000000",
        maxValue: "1000000000",
        code: "#62B58F"
      }
    ]
  },
  dials: {
    dial: [
      {
        value: "4800000"
      }
    ]
  }

}; 


  }

  ngOnInit() {
    debugger;
    this.api.getAllRevenueTarget().subscribe(res => {
      this.TopCustomers = res;      
      this.customerBarChart.data = this.TopCustomers;
      this.TotalRevenue = this.TopCustomers.map(x => x.value).reduce((a, value) => a + value, 0);
      let dials: any;
      var Value = this.revenueTargetProgress.dials.dial[0].value = this.TotalRevenue;
      //Value.dial[0].value = this.TotalRevenue;      
    });



  }



}

Property 'dials' does not exist on type 'Object' getting this error, i'm new to Angular 7 typescript. i want to clear this error that's it. i tried by declaring dials: any; dials: Array; dials: any[] = []; dials: any=[];

The problem is the type of the revenueTargetProgress property.

Object is the type of the the Object javascript prototype. It hasn't much meaning on its own, besides being preceded by extends . You can learn more about the differences between any , Object , object and {} in this thread or this thread .

If you know the type of revenueTargetProgress , you can assign it in place of Object . If you don't know it and you like some degree of risk, you can assign any .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM