Basically scenario is that i am getting URL parameter value in my home component and now i want to use this value on my index.html page.how we can do this?
-
How do you want to use it? As a title?joka00– joka002020-02-10 06:36:12 +00:00Commented Feb 10, 2020 at 6:36
-
As in footer valueahmed raza– ahmed raza2020-02-10 06:41:41 +00:00Commented Feb 10, 2020 at 6:41
-
1Why don't you have the footer in app.component.html?joka00– joka002020-02-10 06:42:16 +00:00Commented Feb 10, 2020 at 6:42
-
i am using header and footer on index.htmlahmed raza– ahmed raza2020-02-10 06:43:15 +00:00Commented Feb 10, 2020 at 6:43
-
It is not clear question.Hamed Baziyad– Hamed Baziyad2020-02-10 07:22:45 +00:00Commented Feb 10, 2020 at 7:22
|
Show 1 more comment
1 Answer
You could use native javascript to set some text.
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. Propably the simplest way to solve your issue.
2 Comments
ahmed raza
can you please let me know if i want to add script file in app.component.html how i can do this?? like currently i am going with your solution to move header footer in app component but i am getting the header footer from some external source or third party. But i don't able to load "script.js" on my appcomponent.html template same script.js is loading on index.html. I am doing like this <script src="script.js"> "script.js can be any third party file name
Jonas
If you can't change how the footer is loaded, then you probably have to use the native js way.