Angular 5-元描述不起作用 [英] Angular 5 - Meta description not working
问题描述
我遇到了Angular的Meta函数的问题.
从'@ angular/platform-browser'导入{Meta};
我已将其添加到我的页面"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();
}
}
你能救我吗? :(
请参阅这是另一个有关如何使用元标记的有用链接. /p>
I got a problem with the Meta function of Angular.
import {Meta} from '@angular/platform-browser';
I have added it on my page "contact.component.ts" but I'm not seeing anything on my web page. There is no meta description or something else.
This is my page code:
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();
}
}
Can you save me ? :(
Refer to 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 is an another helpful link on how the meta tags are used.
这篇关于Angular 5-元描述不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!