Reference.push failed: first argument path specified exceeds the maximum depth
I’m trying to send form data to firebase and route user based on selection. The routing based on selection works , but I get this error when trying to push data
component.ts
export class HomeComponent {
// [x: string]: any;
home:{ name: string ,
age: number,
mobileNo: number,
area: string,
address: string,
test?: string } = {
name:"",
age: null,
mobileNo:null,
area: "",
address:"",
test: null,
}
testMethod = [
{ id:1, name: 'YES' , value:'positive'},
{ id:2, name: 'NO' , value:'negative'},
]
constructor(private homeService: HomeService ,private router: Router ,
public authService: AuthService,
public ngZone: NgZone,
private db: AngularFireDatabase) {
}
save(userDetails){
JSON.parse(JSON.stringify(this.home))
console.log(this.home)
this.homeService.create(userDetails)
// Routing based on user data
if(this.home.test === 'positive'){
this.router.navigateByUrl('positive');
}else{
this.router.navigateByUrl('negative');
}
}
}
Service.ts
constructor( private db: AngularFireDatabase ) {
}
create(userDetails){
return this.db.list('/userDetails').push(userDetails);
}
}[errorwhen trying to push data ][1]
Source: Angular Questions