简体   繁体   English

如何在 angular 8 中获取 index.html 模板上的组件值?

[英]How to get component value on index.html template in angular 8?

基本上情况是我在我的主页组件中获取 URL 参数值,现在我想在我的 index.html 页面上使用这个值。我们如何做到这一点?

You could use native javascript to set some text.您可以使用本机 javascript 来设置一些文本。

public class AppComponent implements OnInit {
    ngOnInit() {
        document.querySelector('#foo').innerText = 'bar';
    }
}

Or just move the header and footer from your index.html into your app.component.html.或者只是将页眉和页脚从 index.html 移动到 app.component.html 中。 Propably the simplest way to solve your issue.可能是解决问题的最简单方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM