相关疑难解决方法(0)

没有Http StaticInjectorError的提供者

我正在尝试从我的api中提取数据,并在我的离子应用程序中填充它,但是当我进入页面时应该填充数据时它会崩溃.以下是我的两个.ts文件:

import { Component } from '@angular/core';

import { NavController, LoadingController } from 'ionic-angular';
import { RestService } from '../../providers/rest-service/rest-service';

@Component({
  selector: 'page-all-patients',
  templateUrl: 'all-patients.html',
  providers: [RestService]
})
export class AllPatientsPage {
  data: any;
  loading: any;

  constructor(public navCtrl: NavController, public restService: RestService, public loadingCtrl: LoadingController) {

    this.loading = this.loadingCtrl.create({
      content: `
        <ion-spinner></ion-spinner>`
    });
    this.getdata();
  }

  getdata() {
    this.loading.present();
    this.restService.getJsonData().subscribe(
      result => {
        this.data=result.data.children;
        console.log("Success: " + this.data);
      },
      err => {
        console.error("Error : " + err);
      },
      () => { …
Run Code Online (Sandbox Code Playgroud)

typescript ionic-framework angular

59
推荐指数
3
解决办法
14万
查看次数

标签 统计

angular ×1

ionic-framework ×1

typescript ×1