Categories
Angular Opinions Tutorials

Understanding Angular Checkbox Directives and Host Binding

Imagine we have directive that customizes the checkbox color and interaction. We want to make our checkbox checked base on certain condition. But line 5, the highlighted one will throw following error. What really happens is that Angular thinks we are binding directive on some host elements (container etc) that doesn’t have checked property. Angular […]

Categories
Angular Tutorials

Tailwind Arbitrary classes in Angular host properties

I wanted to add different classes to the host element based on certain condition. I could add the classes in the accompanying style file. However, they won’t be available to be used on the host element. Unless I change the encapsulation mode to ViewEncapsulation.None. That removes the encapsulation and make the style declarations global. Which […]

Categories
Angular Tutorials

Nice usage of rediretFunction in Angular Router

The rediretTo property in the Router now accepts a function since version 18. That can return a string or UrlTree. I have found one nice use case for it. Imagine you have following routes Here when we visit the /users we are redirected to /users/list. Now you are asked to create one more entry in […]

Categories
Angular Opinions

One less effect to reset signal in Angular

I need to fetch some posts. We will use the httpResource. HttpClient returned observables but this one is reactive wrapper around HttpClient. The response we get is a signal. We can render the content in template as {{ content.value() }} But there is new inquiry. We need filter by specific user, No problem we can […]

Categories
Angular Opinions Tutorials

TIL Week 27 2023: Stow, fzf, Angular Router gotchas

This is regular week update, of things I have discovered in my daily workflow. Its a nice place to come back in future. I also share because this might help other developers. They might come across similiar situation. Stow – Manage config file Up until this point I was only working on single machine to […]