看起来很简单,但我找不到简单的解决方案。 我正在使用标题服务将标题放在文档中。这工作正常,请参阅此处的文档: https://angular.io/guide/set-document-title
我的问题是特殊字符。在我的代码中,标题是由路由服务设置的,但我的页面标题有特殊字符。举个例子:页面标题“Início”,í 字符格式不正确。
Angular 中有一些函数或服务可以做到这一点吗?
我的代码,问题出在setTitle:
AssinarEventosRoute(): any {
this.router.events
.filter((event) => event instanceof NavigationEnd)
.map(() => this.activatedRoute)
.map((route) => {
while (route.firstChild) route = route.firstChild;
return route;
})
.filter((route) => route.outlet === 'primary')
.mergeMap((route) => route.data)
.subscribe((event) => this.titleService.setTitle(`${event['title']} | Gerencial ISP 2`));
}
最佳答案
您必须在 HTML 文件中添加字符集标记:
<meta charset="utf-8">
此外,您的 .ts 文件也应该采用 UTF-8 编码。
关于html - Angular 5设置带有html转义(实体)字符的文档标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49652573/