我决定使用@ angular / fire库
它根本不会在我的html Meta标签打开图中显示SEO你知道的。
此库@ angular / fire与SSR或某些异步主题兼容吗?
我希望得到我的完整TS:
import { PLATFORM_ID, Component, OnInit, ChangeDetectorRef, Inject } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/database';
import { ActivatedRoute } from '@angular/router';
import { SEOService } from 'src/app/services/seo.service';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'app-item',
templateUrl: './item.component.html',
styleUrls: ['./item.component.scss']
})
export class ItemComponent implements OnInit {
loteProducto: any;
productData: any;
settings: any;
imageProduct: any;
SEO_META: any;
productVariants: any;
productDataSEO: any;
constructor(
@Inject(PLATFORM_ID) private platform: Object,
private db: AngularFireDatabase,
private cd: ChangeDetectorRef,
private route: ActivatedRoute,
private SEO: SEOService
) {
this.settings = {};
this.productVariants = [];
}
ngOnInit() {
if(isPlatformBrowser(this.platform)) {
this.db.database.ref("/settings")
.once("value", settings => {
this.settings = settings.val();
this.cd.detectChanges();
});
}
this.route.params.subscribe(params => {
this.loteProducto = params["idLote"];
this.imageProduct = this.loteProducto+"_6";
this.db.database.ref("/productos/")
.orderByChild("lote")
.equalTo(this.loteProducto)
.once("value").then(data => {
data.forEach(item => {
this.productDataSEO = item.val();
this.cd.detectChanges();
});
this.SEO_META = {
"title": this.productDataSEO.descripcion,
"desc": this.productDataSEO.categoria,
"image": `https://repo.lovepayless.com/thumbnail-${this.productDataSEO.lote}_6.jpg`,
}
this.SEO.setSEO(this.SEO_META);
});
});
}
}
[您可以看到我正在使用带有针对OG的元标记更新的SEO服务:facebook开放图协议和针对浏览器SEO的元服务。
我在做什么不好?
操你妈的Google Developers son子!角质是注定要穿的。异步编程吮吸我的家伙!!!