Firebase:Reference.set失败:第一个参数在属性'BFunctions.hallo.DCreationDate'中包含undefined

时间:2018-01-02 12:58:04

标签: javascript angular firebase firebase-realtime-database

我正在努力解决我的Angular应用程序问题。 在我的表单中,我将数据发送到Firebase数据库。我还想将创建日期保存在数据库中。但显然它不再起作用了 - 它以前做过。 我根本不理解错误信息:

ERROR Error: Reference.set failed: First argument contains undefined in property 'BFunctions.hallo.DCreationDate'
    at Object.t.validateFirebaseData (validation.js:103)
    at validation.js:149
    at Object.t.forEach (obj.js:37)
    at Object.t.validateFirebaseData (validation.js:132)
    at Object.t.validateFirebaseDataArg (validation.js:91)
    at t.set (Reference.js:114)
    at BusinessFunctionComponent.fbPostData (business-function.component.ts:67)
    at Object.eval [as handleEvent] (BusinessFunctionComponent.html:17)
    at handleEvent (core.js:13255)
    at callWithDebugContext (core.js:14740)

这是我business-function.component.ts的代码(我删除了不相关的部分):

declare var firebase: any;
const d: Date = new Date();


@Component({
  selector: 'app-business-function',
  templateUrl: './business-function.component.html',
  styleUrls: ['./business-function.component.css'],
  encapsulation: ViewEncapsulation.None,
  providers: [DataService, SearchNamePipe]
})
export class BusinessFunctionComponent implements OnInit {


  name:String;
  descr:String;
  jahr;
  monat;
  tag;
  stunde;
  minute;
  datum;
  liste = [];
  isDesc: boolean = false;
  column: string = 'Name';
  direction: number;



  constructor(
    private dataService: DataService,
    private router: Router, 
    private route: ActivatedRoute,
    private searchName: SearchNamePipe) { 
  }

  ngOnInit() {
    this.jahr=d.getFullYear();
    this.monat=d.getMonth();
    this.minute='hallo';
    this.fbGetData();
    console.log(this.liste)
  }

fbGetData(){

  firebase.database().ref().child('/BFunctions/').orderByChild('CFlag').equalTo('active').
  on('child_added', (snapshot) => {  
  //firebase.database().ref('/BFunctions/').orderByKey().on('child_added', (snapshot) => {
 // alter code ... neuer Code nimmt nur die Validen mit dem X Flag    
  this.liste.push(snapshot.val())
  })
}


fbPostData(name,descr){
 // firebase.database().ref('/BFunctions/').push({Descr: descr, Name: name});
 firebase.database().ref().child('/BFunctions/').child(name).set({
 AName: name ,BDescr: descr, CFlag: 'active', DCreationDate: this.datum //, created: this.creationDate, altered: 'none', removed: 'none'
    });
    this.name = '';
    this.descr = '';

}


}

任何人都可以帮我解决这个问题吗?我感谢所有答案!

0 个答案:

没有答案