Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
πŸ“„ How to design user-friendly forms: Colours

#guide

Colours will not just make your form look better or more engaging, but they will also make it easier for the user to get through each section faster.

Different colours can be used for different purposes. As mentioned before, red is often used to indicate any errors on the form while light grey can used for any disabled fields that we are not allowed to change (see the example below). A soft tone can also be applied to the whole form background to help the user identify each empty field. You can then use prominent and contrasting colours to make users notice action buttons like β€œProceed to payment”, β€œSubmit” or β€œOK”.
β€οΈπŸ“„ How to Implement Compodoc in Your Angular Project

#angular #compodoc #guide

Tips to Maximize the Use of Compodoc

β€” Keep Documentation Updated: Regenerate the documentation whenever you change the code.

β€” CI/CD Integration: Consider integrating Compodoc into the CI/CD pipeline to automate documentation generation.

β€” Consistent JSDoc Comments: Use JSDoc comments consistently to enrich the documentation.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀️ 10 Angular Architecture Mistakes

#angular #info #guide

Not having an architecture (or a plan) at all!
What is unfortunately often forgotten is that if we want to be able to keep moving fast also one year after we started our project, then we also need to make sure that our project doesn’t become an overconnected ball of mud or to use more technical term, we don’t end up with a tangled dependency graph with lot’s of circular dependencies…

One of the best way to know if this is your case is the constant feeling of being stuck in a spider web when trying to fix one thing leads you to a journey of changing half of the codebase, adding condition after condition just to make it work just this one more time.

Not thinking about eager and lazy parts of the app
Typical example is when we have some feature specific service which manages some kind of feature specific state and then we realize that it would be really great to be able to get that state also in some service in the eager core.

In that case, it’s very easy to just import and inject the feature service in the core service and overlook this eager / lazy boundary violation (or just miss it during the PR review). The outcome will be that the service (and everything else it imports) will suddenly become part of the eager Javascript bundle!

This is bad for performance and for architecture as well as we’re introducing dependencies between parts which should have been isolated (or only depend on each other in one direction, eg feature can consume core, but not the other way around!

Not lazy loading ALL the features
Another common offender that tends to happen also in reasonably architected projects is that even though they mostly embraced the eager / lazy split and have most of the logic implemented as the lazy loaded features, for some reason, some of the features are β€œforgotten”…

The best way to remedy this is to always implement everything including the first (original feature) as a first lazy loaded feature.

Using more than one way to achieve the same
Let’s take routing as an example, currently there are at least 4 ways to do it

β€” eager route to a component with component
β€” lazy route to a component with `loadComponent`
β€” lazy route to a module with `loadChildren`
β€” lazy route to routes based feature (feature-x.routes.ts) with `loadChildren`

In this case, we most likely want to pick one and stick with it.

I would personally recommend to always define lazy route with the routes based feature with loadChildren which is the most modern and flexible way of doing things. Then, in case our lazy feature contains sub navigation, we can lazy load additional components with loadComponent .

Focusing on DRY instead of ISOLATION

The DRY is a principle aimed at reducing the code repetition in the codebase, replacing duplicate code with abstractions.

If the same information or logic is repeated in multiple places, any new requirement which necessitates a change in how it should work will require us to change the logic consistently in all these places which can lead to errors and inconsistencies.

The argument we’re trying to make is that in frontend codebases it’s better to have some amount of duplicated code (e.g. in multiple lazy features) because that will allow them to evolve independently as the requirements change, and they do change!

Madge
Madge is a developer tool for generating a visual graph of your module dependencies, finding circular dependencies, and giving you other useful info

β€” madge npm docs

Not using standalone components

Using standalone components instead of NgModules means that our dependency graph becomes more granular and this higher resolution allows us to gain better insight of how each parts of app relate to each other and discover more issues!
Besides that, it allows lazy features to cherry pick only those UI components which is actually needs instead of depending on all of them, as was often the case when applications grouped and exposed them in commonly used SharedModule !


βœ…
Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3πŸ‘1
πŸ“„ How to design user-friendly forms: Validation and errors

#guide

Before a form is submitted, validation takes place. This means that required fields must be completed and input values must have a correct format. If something is wrong or missing, an error message will be shown to help the user meet the requirements.

Three types of error messages might appear in your form:

1) An error has occurred: It is necessary to clearly show that an error has occurred when filling out the form. Ideally, this message is shown in red colour;

2) Where the error occurred: It is necessary to highlight the field in which the error occurred;

3) How the error can be fixed: Put information on what needs to be different for the form to be validated correctly.

It’s important to note that the list of errors will be read by screen readers making your website accessible. Once all the checks have passed, the form can be successfully submitted.
❀1
πŸ“„ How to design user-friendly forms: Optional vs. required

#guide

When designing forms, we often include both optional and required fields. Typically, we designate a required field by adding an asterisk (*) to it. Although we still find this method applied, it is increasingly being replaced by a different approach that uses words instead of symbols to indicate optional fields. Forms should collect the most important information and have a few optional fields. This will make it easier for people to comprehend the information, without overwhelming them with it.

This method offers a more intuitive approach, particularly for forms that are more extensive and complex.
🌐 πŸ’˜ Lightweight NGRX signalStore with Angular. Complete guide

#angular #signals #signalStore #guide

What is NGRX signalStore?
NgRx SignalStore is a fully-featured state management solution that offers a robust way to manage application state. With its native support for Signals, it provides the ability to define stores in a clear and declarative manner. The simplicity and flexibility of SignalStore, coupled with its opinionated and extensible design, establish it as a versatile solution for effective state management in Angular.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1πŸ‘1
❀️ Setting Up Environment Variables in Angular

#angular #env #guide

Environment variables are a way to configure different settings for various environments without changing the application’s code. This is particularly useful for handling API endpoints, feature flags, and other configuration settings that vary between environments.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯1
πŸ“„ How to design user-friendly forms: Add visual cues

#guide

Incorporating visual cues into the form is another way to enhance the user experience. Captions should be used along with any visual cues to make the form more engaging, accessible and user-friendly.
πŸ†š Useful CSS Properties

#css #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀️🩢 Advanced Typing and Error Interceptor with Services Strategy

#angular #services #strategy #pattern #error #errorHandling #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀️ How to Upload Excel Data in Angular

#angular #excel #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘2
πŸ“΅ Understanding The Secret Power of Generators

#js #generators #guide

When to Choose Which?

Use generators when:

β€” You need to manage complex control flows with precision.
β€” Memory efficiency is critical, and you want to generate values on demand.
β€” You’re implementing patterns like state machines or lazy iteration.

Use promises when:

β€” You’re handling simple asynchronous operations.
β€” You need to work with concurrent tasks.
β€” You prefer simpler, more straightforward error handling.

Best Practices for Using Generators:

1. Keep It Simple
Generators can add complexity to your code, so use them judiciously. If a task can be easily handled with promises or async/await, there’s no need to reach for generators.

2. Combine with Promises for Maximum Effect
Generators and promises are not mutually exclusive. In fact, they can complement each other beautifully. For instance, you can use a generator to structure your async flow and promises to handle the actual asynchronous operations.

3. Mind the Iteration
When using generators for iteration, always be mindful of when to stop. An infinite loop in a generator can be a real headache if not properly managed. Ensure you have clear exit conditions if your generator has the potential to run indefinitely.

4. Test Thoroughly
Given the unique execution flow of generators, thorough testing is crucial. Ensure that all possible execution paths are covered, including edge cases where the generator might yield unexpectedly or be terminated early.

5. Leverage TypeScript for Type Safety
Since you’re writing in TypeScript, make sure to define the types for your generator functions. This adds an extra layer of safety, helping you catch potential issues at compile time.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸŒπŸ’  Angular 18 SSR docker env

#angular #docker #env #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘2
❀️ Trigger Fullscreen Mode for Any Element

#angular #viewChild #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘2
πŸ†š A Scalable CSS Architecture for Modern Web Applications

#css #info #guide

The Core Challenge of Scaling CSS

As applications evolve, managing styling consistently becomes even harder. Web projects often face issues like:

β€” Inconsistent UI elements: Without a unified system, different pages or features can drift apart visually.
β€” Hard-to-maintain styles: Styling becomes scattered and unorganized, making future changes tedious and error-prone.
β€” Difficulty in updating themes or branding: Modifying a color or spacing may involve updating hundreds of individual styles.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘4
πŸ€“β€οΈ 10 Commonly Made Coding Mistakes in Angular

#angular #guide #info

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘3
πŸ†š CSS New Features

#css #guide #info

This is a list of the new changes (more details below):

β€” Changes to attr() function: so it can be used with any attribute and in any CSS property (not only on content).

β€” calc-size() function: use intrinsic values such as auto or min-content in calculations.

β€” New first-valid() function to avoid issues with custom properties with invalid values.

β€” New *-mix() family of functions with a new notation for ratios.

β€” New *-progress() family of functions to calculate the progress ratio between a range or within a media or container.

β€” Randomization with new random() and random-item() functions, to return random values from a range or list (finally!)

β€” New sibling-count() and sibling-index() functions that provide integer values to operate depending on the order and size.

β€” New toggle() function for styling nested elements easily cycling over a list of values.

β€” New functional notation for arguments with comma-separated lists of values, to avoid ambiguity with the comma separating the arguments.

β€” New URL modifiers to provide more control over url() requests.

β€” Extension of the position type to allow flow-relative values.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘5
❀️ OAuth2 Integration with Angular 18

#angular #OAuth2 #guide

OAuth2 is a popular authorization framework that allows third-party services to authenticate users without sharing credentials. It’s a powerful protocol for securing Angular applications by delegating authentication and authorization to a trusted identity provider like Google, Facebook, or your own backend server.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘2