Refactor Reactive Form with components in Angular

Loading

Reading Time: 5 minutes Introduction The simple CSS grid generator has three reactive forms while these forms have material components that behave similarly. In grid form. Grid gap is a number input field and Gap unit is a drop down list. Similarly, Grid Column Gap and Grid Column Unit are number input field and drop down list respectively. We … Read more

Generate Dynamic Reactive Form in Angular

Loading

Reading Time: 5 minutes Introduction I wrote a small Angular application to learn CSS grid a few years ago. The application has a reactive form with three form groups to input data to generate CSS grid codes. Defining similar form groups is tedious; therefore, I decide to generate dynamic reactive form based on the form group configurations. In this … Read more

Generate i18n pdf invoice in nestjs app with nestjs-i18n

Loading

Reading Time: 7 minutes Introduction This project is a proof of concept (POC) to generate i18n pdf invoice using nestjs-i18n and html2pdf. In this use case, the i18n language comes from database instead of http request. It is because scheduled job generates and sends out invoices on a monthly basis that does not involve HTTP communication. After retrieving the … Read more

Add i18n translation to emails in nestjs app with nestjs-i18n

Loading

Reading Time: 6 minutes Introduction This project is a proof of concept (POC) to apply i18n translation to emails. Our vendor has a different solution to translate emails at work; therefore, this solution is not picked up. Nonetheless, I want to show my work in this post to demonstrate how to use nestjs-i18n library to translate the content of … Read more

Add i18n support in nest app with nestjs-i18n

Loading

Reading Time: 7 minutes Introduction Many enterprise applications support multiple languages nowadays to cater to customers whose first language is not English. In nest application, we would like to add i18n support to return i18n messages to client-side applications such that users can respond with appropriate actions. Nest framework does not have i18n out of the box but we … Read more

Dynamically load components in Angular 13

Loading

Reading Time: 3 minutes Introduction Dynamically load components has simplified in Angular 13. Angular team deprecated ViewContainerRef in Angular 13 and we can load components to attached view container without it now. Let’s recap how we load components in Angular 12. We inject ComponentFactoryResolver to map component to ComponentFactory. Then, we pass the ComponentFactory to ViewContainerRef to create an … Read more

Split module into single component angular modules (SCAMs)

Loading

Reading Time: 6 minutes Introduction When Angular application grows, developers start to build new components and add them into modules. When we put every component into a single module, not only the module becomes bloated but also cannot identify related resources (components, pipes, directives, etc) that can bundle together. In order to avoid bloated module in an Angular application, … Read more

Functional composition with compose and pipe in lodash/fp

Loading

Reading Time: 3 minutes What is functional composition? Functional composition is the technique of composing multiple functions into a complex function. In Mathematic definition, f(x) and g(x) are functions and h(x) is the composed function of f and g. Functional composition is an efficient technique in processing list data and it is preferred over calling chained array methods to … Read more

Customize template with ngTemplateOutlet and ngTemplate in Angular

Loading

Reading Time: 4 minutes Introduction When Angular components require to render ngTemplates programmatically, ngif-then-else construct takes care of most of the scenarios. However, ngIf is lack of passing context that ngTemplateOutlet directive supports. If either template depends on inputs or calculated data of component, then we can pass the values to them via template context of ngTemplateOutlet directive. The … Read more

How to perform accessibility testing in Angular and Storybook

Loading

Reading Time: 4 minutes Introduction Accessibility testing is an important aspect of Angular and Storybook development because applications should be accessible to disabled individuals. For example, people who suffer from color blindness can not see red and green, and developers should render texts in different colors. When developing accessible applications in Angular, we can add aria attributes to HTML … Read more