タグを削除しようとすると、角4.7にあるMetaの概念を持つindex.htmlで動的にタグを設定できます。 を削除しないでください。以前に追加したタグは何ですか?ここ角4のメタを使用してタグを削除するには
は、私が試したものです。タグを設定 :破壊する方法で
import {Meta ,MetaDefinition } from '@angular/platform-browser';
@Component({
selector: 'app-share-video',
templateUrl: './share-video.component.html',
})
export class ShareVideoComponent implements OnInit {
constructor(public metaServic:Meta){}
ngOnInit(){
const ogtitle: MetaDefinition = { name: 'og:title', content: 'Grace' };
const ogSitename: MetaDefinition = { name: 'og:site_name', content: 'My Favourite Albums'};
const ogUrl: MetaDefinition = { name: 'og:url', content: 'https://angular.io/docs/ts/latest/api/platform-browser/index/Meta-class.html'};
const ogdesc: MetaDefinition = { name: 'og:description', content: 'angular 4 share video description'};
this.metaService.addTag(ogtitle);
this.metaService.addTag(ogSitename);
this.metaService.addTag(ogUrl);
this.metaService.addTag(ogdesc);
}
ngOnDestroy() {
this.metaService.removeTag("property='og:title'");
this.metaService.removeTag("property='og:site_name'");
this.metaService.removeTag("property='og:url'");
this.metaService.removeTag("property='og:description'");
}
}
私はタグを削除していますが、これらのタグが削除されていない、どのように私は、タグを削除することができますか? これに続く:meta tags blog
の
を使用する必要が
はあなたの破壊が呼ばれているのですか?あなたは確認しましたか? – CharanRoot
呼び出し元の破棄メソッド –
コードに問題はありません。このthis.meta.addTag({name: 'og:title'、内容: 'Grace'})のようにしてください。まだ動作していない場合は、deletetagを取得してコンソールログを出力してください。 – CharanRoot