小编Him*_*shu的帖子

如何通过firebase实时更新ng2-charts中的值

我对angular2完全不熟悉.我的问题是我通过ng2-charts lib创建了一个条形图,并使用angularfire2将其链接到firebase.我有2个组件和一个服务,用于向我的firebase数据库发送和接收数据.我可以doctor-local.component.ts通过my 将一个组件中的数据发送到firebase,data.service.ts并在我的接收上doctor-expert.component.ts保存数据,并使用firebase数据库中的值保持同步,并使用(ngModelChange)事件绑定实时显示在同一个组件中.条形图也在此组件中.

这是我expert.component.tsdoctor-expert.component.html

import {Component} from '@angular/core';
import {DataService} from '../data.service';
import {FirebaseObjectObservable} from 'angularfire2';

@Component({
  selector: 'app-doctor-expert',
  templateUrl: './doctor-expert.component.html',
  styleUrls: ['./doctor-expert.component.css']
})
export class DoctorExpertComponent {
  public items: FirebaseObjectObservable<any>;
  
  public barChartOptions: any = {
    scaleShowVerticalLines: false,
    responsive: true
  };
  public barChartLabels: string[] = ['RBC Count', 'WBC Count', 'Haemoglobin'];
  public barChartType: string = 'bar';
  public barChartLegend: boolean = true;
  rbc: number;
  wbc: number;
  haemo: number;


  public barChartData: any[] …
Run Code Online (Sandbox Code Playgroud)

firebase ng2-charts angular

2
推荐指数
1
解决办法
1821
查看次数

标签 统计

angular ×1

firebase ×1

ng2-charts ×1