Friday, May 22, 2020

Change dynamic value mat icon Angular 8 or greater


I share example how to change dynamic value mat icon with Angular.


Example, In my case, I want to change mat-icon expand_less to expand_more

HTML
 <button mat-icon-button color="primary">
   <mat-icon id="mat-{{name_dynamic_id}}" matTooltip="" aria-label="">
expand_less
</mat-icon>
 </button>

TS, Use native javascript.

Get Id.

var dynamicMatIccon = document.getElementById("mat-" + value);

Change value:

dynamicMatIccon.innerHTML = "expand_more";


That it is.


No comments:

Post a Comment

Virtual Threads in Java 21: Simplified Concurrency for Modern Applications

  With Java 21, Virtual Threads have redefined how we approach concurrency, offering a lightweight and efficient way to handle parallel and ...