facebook - Data Binding in Angular 2 -
i have id value in product.projectid.
value in product.projectid:= 45414424 trying share page link on facebook. how bind project.projectid in below scenerio?
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php? u=https://stackoverflow.com/questions/45414424/&src=sdkpreparse"> facebook </a>
below doesn't seems working in case.
{{product.projectid}}
code component.ts:
ngoninit(): void { this.sub = this._route.params.subscribe( params => { let id = +params['id']; this.getproduct(id); }); } ngondestroy() { this.sub.unsubscribe(); } getproduct(id: number) { this._productservice.getproject(id).subscribe( product => this.product = product, error => this.errormessage = <any>error); }
code services:
getprojects(): observable<iproject[]> { return this._http.get(this._projecturl) .map((response: response) => <iproject[]> response.json()) .do(data => console.log('all: ' + json.stringify(data))) .catch(this.handleerror); } getproject(id: number): observable<iproject> { return this.getprojects() .map((products: iproject[]) => products.find(p => p.projectid === id)); } private handleerror(error: response) { console.error(error); return observable.throw(error.json().error || 'server error'); }
project interface
export interface iproject { projectid: number; projectname: string; projectby: string; projectdescrition: string; }
Comments
Post a Comment