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

Integrating Google Cloud Pub/Sub with Terraform and Spring Boot 3 (Java 21)

Introduction In this blog post, I'll demonstrate how to provision Google Cloud Pub/Sub resources using Terraform and integrate them with...