We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Programmatically change themein Angular 4


How can I programmatically change Theme in Angular 4?

1 Reply

SS Subha Shree Ramanathan Syncfusion Team August 18, 2017 11:22 AM UTC

Hi Me, 

Thanks for contacting Syncfusion Support. 

Based on theme selection, we can dynamically replace the corresponding theme file (ej.web.all.min.css) referred in index.html file. Refer to the below code snippet to change the theme. 


  updateLinkTag(theme) { 
    this.links = jQuery(document.head || document.getElementsByTagName('head')[0]).find("link"); 
    for (let i = 0; i < this.links.length; i++) { 
      if (this.links[i].rel='nofollow' href.indexOf("ej.web.all.min.css") != -1) { 
        this.links[i].rel='nofollow' href = "node_modules/syncfusion-javascript/Content/ej/web/" + theme + "/ej.web.all.min.css"; 

Here we rendered the ejDropDownList to list the needed themes. While selecting the theme in dropdownlist, we changed the theme in index.html file. 


<div class="dropdownclass"> 
        <input id="dropdown" ej-dropdownlist [dataSource]="data" [fields]="fieldsvalues" [(value)]="value" (select)="selectlist($event)" [selectedIndex]=1 /> 

For your convenience we prepared the sample to achieve the requirement. 

Please let us know if you need further assistance on this. 

Subha Shree D.R                                                                     

Live Chat Icon For mobile
Up arrow icon