我想知道我是否有机会隐藏我的简单网站是用 Angular 制作的。我可以在网站上看到这个
<app-root _nghost-iie-c28="" ng-version="11.0.4"><router-outlet _ngcontent-iie-c28="">
,并认为所有 Angular 网站都有这些标签,但没有。那么,我可以通过什么方式隐藏它们呢?
相关门票
只需添加根组件即可删除版本属性:
@Component({
selector: '[data-app]',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(private _elementRef: ElementRef) {
}
ngOnInit(): void {
this._elementRef.nativeElement.removeAttribute("ng-version");
}
}
当涉及到
_nghost
属性时,您似乎无法以设置应用程序的方式摆脱它,因为它指向填充内容的位置,但是您可以创建一个新组件并在那里添加路由,以便它显示在树的更下方如果您不想将其放在根组件中。
注意: 正如票证相关讨论中提到的,这可能主要用于生产构建,因为某些工具依赖于开发构建的属性。