+
+
+
+
+
+
{{product.name}}
{{product.price | currency}}
Contact For Price
diff --git a/src/app/store/products/products.component.ts b/src/app/store/products/products.component.ts
index d3c107e..88388e6 100644
--- a/src/app/store/products/products.component.ts
+++ b/src/app/store/products/products.component.ts
@@ -1,7 +1,9 @@
import {Component} from '@angular/core';
-import {AngularFirestore} from '../../../../node_modules/angularfire2/firestore';
-import {ActivatedRoute} from '../../../../node_modules/@angular/router';
-import {DomSanitizer} from '../../../../node_modules/@angular/platform-browser';
+import {AngularFirestore} from 'angularfire2/firestore';
+import {ActivatedRoute} from '@angular/router';
+import {DomSanitizer} from 'node_modules/@angular/platform-browser';
+import {AppComponent} from '../../app.component';
+import {map} from 'rxjs/operators';
@Component({
selector: 'products',
@@ -10,19 +12,31 @@ import {DomSanitizer} from '../../../../node_modules/@angular/platform-browser';
export class ProductsComponent {
product;
- constructor(private route: ActivatedRoute, private db: AngularFirestore, private domSanitizer: DomSanitizer) {}
+ constructor(
+ private route: ActivatedRoute,
+ private db: AngularFirestore,
+ private domSanitizer: DomSanitizer,
+ public app: AppComponent
+ ) {}
ngOnInit() {
this.route.params.subscribe(params => {
this.db
.collection('products', ref => ref.where('name', '==', params['product']))
- .valueChanges()
+ .snapshotChanges()
+ .pipe(
+ map(rows =>
+ rows.map((row: any) => Object.assign({id: row.payload.doc.id}, row.payload.doc.data())).map((row: any) => {
+ row.image = this.domSanitizer.bypassSecurityTrustUrl(row.image);
+ row.description = this.domSanitizer.bypassSecurityTrustHtml(
+ row.description.replace(/(\r\n|\r|\n)/g, '
')
+ );
+ return row;
+ })
+ )
+ )
.subscribe(data => {
this.product = data[0];
- this.product.image = this.domSanitizer.bypassSecurityTrustUrl(this.product.image);
- this.product.description = this.domSanitizer.bypassSecurityTrustHtml(
- this.product.description.replace(/(\r\n|\r|\n)/g, '
')
- );
});
});
}