I'm trying to build a feature for my website in which I'm providing user to change theme of the site according to them. Just getting started, I thought to keep 'Dark theme'. So, I'm trying to implement the dark theme separately.
As you can see above in the screenshot, a modal opens up in which a user can click on dark theme and change the colors of site. This modal component is called customize.component.html
. In the background, you can see the results of website. I call this results.component.html
.
customize.component.ts
<link type="text/javascript" href="../../assets/themes/theme.js" id="theme">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<!-- Start ignoring HTMLLintBear -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<!-- Stop ignoring HTMLLintBear -->
<h2 class="modal-title" id="my-modal-label">Customization</h2>
</div>
<div class="modal-body">
<button class="theme-button" id="dark" onclick="darkTheme(title)">Dark Theme</button>
</div>
</div>
</div>
results.component.ts
<!-- Customization modal-box -->
<link type="text/javascript" href="../../assets/themes/theme.js">
<div class="modal fade" id="customization" tabindex="-1" role="dialog" aria-labelledby="myModallabel">
<app-customize></app-customize>
</div>
This is my code snippet for both the components. I have created another file name theme.js
in where theme-process will work. But my code is not working.
theme.js
function darkTheme(id) {
var el = document.getElementById(id);
el.style.color = "red";
}
How should I take element with an id from results.component.ts
? I'm not able to implement the feature. It would be great if someone can help me out! Thanks!
NOTE - I'm not using Angular Material 2 in my project. So, I have to implement the feature of providing themes to user without using Angular Material 2.