In my service file:
postDetail: FirebaseObjectObservable<any>;
constructor( private af: AngularFire ) { }
public getBanquetDetail(id){
this.postDetail = this.af.database.object('/Posts/'+id) as FirebaseObjectObservable<Post>;
return this.postDetail;
}
In my component.ts file
export class PostDetailComponent implements OnInit {
id: any;
test: any;
constructor(private banquetService: PostService, private router: Router, private route: ActivatedRoute) { }
ngOnInit() {
// Get the id
this.id = this.route.snapshot.params['id'];
this.banquetService.getBanquetDetail(this.id).subscribe(response => {
console.log(response)
this.test = response
})
}
}
I am getting an object in console but couldnt render the value as
<h2>{{test.title}}</h2>
I am getting error as :
TypeError: Cannot read property 'title' of undefined
Anyone please help me? Where am I worng?