0
を読んだことができない私はionic2例に問題を持って、私は私のモジュールからPouchDbにデータを追加するサービス(birthday.service.ts)(details.ts)イオン2は、プロパティ
whith pouchdb関数を呼び出そうけど22:18によって引き起こさ:未定義
私のサービスのプロパティ「ポスト」を読み取ることができません:birthday.service.ts - :
例外:インラインテンプレート./DetailsPageクラスDetailsPageでエラーが発生しました私はこのエラーを持っています
import{Injectable} from '@angular/core';
import PouchDB from 'pouchdb'
@Injectable()
export class BirthdayService {
private _db;
private _birthdays;
initDB(){
this._db = new PouchDB('http://localhost:5984/birthday4');
}
add(birthday) {
return this._db.post(birthday);
}
私のモジュール:detail.ts
import { Component } from '@angular/core';
import { NavParams,ViewController} from 'ionic-angular';
import {BirthdayService} from '../../app/services/birthday.service';
@Component({
templateUrl: 'details.html',
providers:[BirthdayService]
})
export class DetailsPage {
public birthday;
public isNew = true;
public action = 'Add';
public isoDate = '';
constructor (private viewCtrl: ViewController,
private navParams: NavParams,
public birthdayService : BirthdayService
) {
this.birthday = this.navParams.get('birthday');
this.birthday = {Name:" "}
this.isNew=true;
}
save() {
this.birthday.Date = new Date(this.isoDate);
if (this.isNew) {
this.birthdayService.add(this.birthday)
.catch(console.error.bind(console));
} else {
this.birthdayService.update(this.birthday)
.catch(console.error.bind(console));
}
this.dismiss();
}
}
それを実装した後、
ngOnInit()
にinitDb()
を変更しようとすることができundefined
に等しく、ありがとう、私のモジュールでサービスを呼び出す方法 – fansz
fe – Ivaro18
私はこのエラーがあります。プロパティ 'birthdayService'がタイプ 'MyApp'に存在しません – fansz