en
Feedback

Don't get caught by a cheater! Telemetrio finds and tags such channels 👉 If you want to see the tag, subscribe

Angular 🇺🇦 - practical notes

Angular 🇺🇦 - practical notes

Open in Telegram

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!

Show more
1 631
Subscribers
No data24 hours
+17 days
No data30 days
Posts Archive
❤️ 10 Angular Architecture Mistakes #angular #info #guide Not having an architecture (or a plan) at all! What is unfortunatel
❤️ 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

🇺🇦❤️🇮🇳
🇺🇦❤️🇮🇳

🌐 Angular @let declarations: Smart Template Subscriptions #angular #rxjs #shareReplay #let ✅ Article link
+3
🌐 Angular @let declarations: Smart Template Subscriptions #angular #rxjs #shareReplay #let ✅ Article link

🌐 Dynamic Render Component in A18 #angular #signals #input #dynamic #ngComponentOutlet ✅ Article link
🌐 Dynamic Render Component in A18 #angular #signals #input #dynamic #ngComponentOutlet ✅ Article link

❤️📄 How to Implement Angular Micro-Frontends with Module Federation #angular #moduleFederation What is micro-frontend ? Micr
+5
❤️📄 How to Implement Angular Micro-Frontends with Module Federation #angular #moduleFederation
What is micro-frontend ? Micro-frontends are a way to break down a large frontend application into smaller, independently deployable modules, similar to microservices on the backend. Angular micro-frontends use Webpack 5’s Module Federation feature to enable this architecture. Module Federation allows multiple teams to build and deploy features in isolation while composing them together at runtime. Why Micro-Frontends? Micro-frontends bring several benefits to modern web development: — Independent Deployment: Teams can build, test, and deploy individual parts of the frontend independently. — Better Scalability: Teams can work on their domain-specific features without interference from other teams. — Technology Agnostic: Different micro-frontends can use different frameworks. What is Module Federation? Module Federation is a feature in Webpack 5 that allows multiple applications to share code or load remote code at runtime. This is especially useful for micro-frontends, as it allows one Angular application to load modules from another application seamlessly. How to Implement Angular Micro-Frontends Using Module Federation We will break the setup into two parts: — Host Application: The main shell that loads different micro-frontends. — Remote Applications: Individual Angular micro-frontend apps that are federated into the host.
✅ Article link

❤️📄 How to Implement Compodoc in Your Angular Project #angular #compodoc #guide Tips to Maximize the Use of Compodoc — Keep
+5
❤️📄 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

🆚 CSS class naming conventions #css #bem #smaCSS #ooCSS ✅ Article link
+3
🆚 CSS class naming conventions #css #bem #smaCSS #ooCSS ✅ Article link

🌐 Optimize Angular Apps with Unused Standalone Imports Diagnostic in v19 #angular #standalone One of the most anticipated fe
🌐 Optimize Angular Apps with Unused Standalone Imports Diagnostic in v19 #angular #standalone
One of the most anticipated features since the introduction of standalone components is the ability to detect whether a component or directive imported into a component is actually being used. In Angular v19, this need has finally been addressed with the addition of a diagnostic for unused standalone imports. The unused import diagnostic is reported as a warning, giving developers a heads-up without blocking the build. This can be especially helpful during development, allowing teams to catch unused imports early in the process. If needed, the diagnostic behavior can be disabled using the unusedStandaloneImports option in the tsconfig.json.
✅ Article link

📄 How to design user-friendly forms: Colours #guide Colours will not just make your form look better or more engaging, but t
📄 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”.

❤️ 🤓 Angular Animations Functions #angular #animations #ui_element
Example explanation: Triggers (trigger): parentTrigger: Defines animations for the parent element. childTrigger: Defines animations for the child elements. States (state): parentTrigger: Has the states start and end. childTrigger: Has the states visible and hidden. Styles (style): Defines final and intermediate styles for different states and transitions. Transitions (transition): Defines how the animation should occur between states. Animate (animate): Defines the duration and timing function of the animations. Keyframes (keyframes):| Used in the transition from visible to hidden in the child elements to create detailed intermediate animations. Group (group): Used in the transition from start to end in parentTrigger to animate multiple properties in parallel. Sequence (sequence): Used in the transition from end to start in parentTrigger to animate multiple properties in sequence. Query (query): Used in the transition from hidden to visible in childTrigger to select and animate child elements. Stagger (stagger): Used with query to apply a delay between the animations of the child elements, creating a cascading effect.
✅ Article link 🎁 Code Link

❤️ 🔱 Implementing SSR with Angular to Improve SEO #angular #ssr #guide What is Server-Side Rendering (SSR) ? SSR is the proc
+4
❤️ 🔱 Implementing SSR with Angular to Improve SEO #angular #ssr #guide
What is Server-Side Rendering (SSR) ? SSR is the process of rendering web pages on the server instead of in the browser. With SSR, the Angular application sends fully rendered HTML from the server to the client, instead of a set of JavaScript files that the browser needs to process to build the page. Benefits of SSR for SEO 1 — Fast Initial Load: Server-rendered pages load faster, providing a better user experience. 2 — Improved Indexing: Search engines can index server-rendered content more effectively than client-rendered content. 3 — Enhanced Link Sharing: Links shared on social media display rich and informative previews.
✅ Article link

🌐 Signals communication between components #angular #signals #guide ✅ Article link
+3
🌐 Signals communication between components #angular #signals #guide ✅ Article link

💙 Render Angular Components in Markdown #angular #markdown #guide ✅ Article link 🎁 Code Link
+4
💙 Render Angular Components in Markdown #angular #markdown #guide ✅ Article link 🎁 Code Link

📵 Optimizing JavaScript’s Event Loop #settimeout #setinterval #event_loop #requestAnimationFrame Why setTimeout is Inaccurat
+1
📵 Optimizing JavaScript’s Event Loop #settimeout #setinterval #event_loop #requestAnimationFrame
Why setTimeout is Inaccurate? ❌ setTimeout and setInterval in JavaScript are based on the event loop and task queue. Their execution time may vary due to several factors: Event Loop Mechanism: JavaScript executes code within a single event loop. If earlier tasks take a long time or the task queue is busy, the timer callback will be delayed. Task Queue Priority: The priority of tasks in the task queue varies. User interaction events or rendering updates might have higher priority than setTimeout and setInterval, delaying their execution. JavaScript Engine Limitations: The JS engine normally imposes a minimum delay; for example, nested setTimeout calls usually have a minimum delay of 4 milliseconds. System Performance and Load: System performance and current load can also affect timer accuracy. High system load can further delay task execution.
✅ Article link

📄 How to design user-friendly forms: Write clear labels #guide The labels should be simple and easy to understand so that th
📄 How to design user-friendly forms: Write clear labels #guide
The labels should be simple and easy to understand so that the user can quickly see what information to put in each field. Use simple labels to explain simple fields and add as few words as possible for each label. Here’s an easy example: use the “Full Name” label instead of “My name is”.

💙 Using Document API for Dynamic Component Creation #angular #cdk #directives #dynamic Use Case This method can be used when
💙 Using Document API for Dynamic Component Creation #angular #cdk #directives #dynamic
Use Case This method can be used when you need to manipulate the DOM directly, often in scenarios where you are working with non-Angular libraries or need to integrate with existing DOM elements that are not part of Angular’s template system. Pros — Direct control over the DOM. — Can be useful for integrating with non-Angular libraries or existing scripts that manipulate the DOM directly. Cons — Bypasses Angular’s change detection and lifecycle hooks. — Can lead to issues with Angular’s dependency injection and component lifecycle management. — Harder to maintain and debug. Performance Impact Potentially high impact due to bypassing Angular’s optimized change detection. Direct DOM manipulation can also lead to performance issues if not handled properly.
✅ Article link

📄 How to design user-friendly forms: Group fields #guide Sometimes, forms can be very long and complex so it’s best to have
📄 How to design user-friendly forms: Group fields #guide
Sometimes, forms can be very long and complex so it’s best to have clusters of information that contain titles, subtitles, or even descriptions that can facilitate the user’s experience. By organising the information into blocks, the user can quickly connect each type of information. With the main information located vertically, any additional information or instructions can be added to the left section. When adopting this method, make sure you leave space between each section so the user can easily tell which one it is.

📄 Implement the Chainable Utility Type #ts #types #patterns ✅ Article link
+1
📄 Implement the Chainable Utility Type #ts #types #patterns ✅ Article link

📄 How to design user-friendly forms: Aligning sections #guide Aligning sections may seem like a tiny detail but in reality,
📄 How to design user-friendly forms: Aligning sections #guide
Aligning sections may seem like a tiny detail but in reality, it makes a huge difference. The idea is to make a form easier to read by putting all the information in one direction. Users are most likely to look at your information vertically, as it’s faster and more efficient to understand all the information. With this in mind, ideally, you want to make the field names of your form vertical which will make it more accessible and help you limit any potential errors in data collection.

❤️ Angular Design Patterns: Composite #angular #patterns #composite The Composite pattern defines two basic types of elements
+4
❤️ Angular Design Patterns: Composite #angular #patterns #composite
The Composite pattern defines two basic types of elements sharing the same interface: simple leaves and complex containers. A container can consist of both leaves and other containers. This allows for the construction of a nested, recursive structure of objects resembling a tree.
✅ Article link