#angular #standalone
Using standalone components gives you more control over your components compared to the traditional NgModules approach. It allows you to import components directly into each other without the need to go through modules. Standalone components help reduce the number of modules in your project, which translates to less code to manage.
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π1
#angular #inject
In this section, I want to emphasize the importance of using the utility function inject() for service or component injection, rather than relying on the traditional constructor-based approach. The inject() function is more flexible and allows for cleaner, more readable code. It simplifies testing, supports better dependency management, and aligns with Angular's ongoing improvements to enhance the developer experience. By adopting inject(), you can take advantage of a more modern and efficient way to handle dependency injection in Angular applications.
Please open Telegram to view this post
VIEW IN TELEGRAM
π3
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯4π2
#js #trycatch
An amazing new JavaScript operator has arrived and things are not looking too good for try-catch!
While we wait for ?= to become natively integrated into JavaScript, we can start it now with this polyfill
β Article Link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π1
#angular #signals #service #matchMedia
To achieve the desired outcome, Iβve opted for an approach that follows this pattern:
β Create a service with a `mediaQuery()` method, which returns an RxJS Observable containing information on whether a specific breakpoint is matched or not.
β Create a property inside the component class (in the example we will call it `isMobile`, since we have only one breakpoint) and bind it the the `mediaQuery()` method previously crafted, but also converting the Observable to a signal.
β Utilize the `NgClass` directive to dynamically apply a class based on the value of the `isMobile` property.
β Article Link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π1