Angular 5 - 元描述无效

Angular 5 - Meta description not working

Angular 的 Meta 函数有问题。

import {Meta} from '@angular/platform-browser';

我已将它添加到我的页面上 "contact.component.ts" 但我在我的网页上没有看到任何内容。没有元描述或其他内容。

这是我的页面代码:

import {Meta} from '@angular/platform-browser';


@Component({
  selector: 'app-contact',
  templateUrl: './contact.component.html',
  providers: [],
  styleUrls: ['contact.component.css']
})

export class ContactComponent implements OnInit {

  constructor(public meta: Meta, public http: Http, public router: Router, public RequestService: RequestService, public global: GlobalService) {
    this.meta.addTag({ name: 'description', content: 'This is metadata' });
  }

  ngOnInit() {
    this.global.redirectionIfNoConnecte();
    this.global.getJsonLanguage();
  }

}

你能救我吗? :(

参考 this, The HTML meta tag provides metadata about the HTML document. Metadata aren’t displayed on the page but are machine parsable. Meta elements are typically used to specify the page description, keywords, author, last modified, and other metadata. The metadata can be used by browsers (how to display content or reload the page), search engines (keywords), or other web services. Meta tags play an important role in SEO. This 是另一个有用的 link 关于如何使用元标记。

import {
    Meta
} from '@angular/platform-browser';


@Component({
    selector: 'app-contact',
    templateUrl: './contact.component.html',
    providers: [],
    styleUrls: ['contact.component.css']
})

export class ContactComponent implements OnInit {

constructor(public meta: Meta, public http: Http, public router: Router, public RequestService: RequestService, public global: GlobalService) {
    meta.addTag({
        name: 'description',
        content: 'This is metadata'
    });
}

ngOnInit() {
    this.global.redirectionIfNoConnecte();
    this.global.getJsonLanguage();
}

}