Skip to content

[TECH] Conditionner le rendu des modal

Contexte

La condition pour afficher certaines modales est dupliquée

image

Dans le composant

image

Objectif

  • Retirer les props [openned] et conditionner le rendu sur les parents avec ngIf.
  • Ajouter des handle (close) qui géreront l'affichage dans le composant parent

Ceci devrait rendre moins de html. Vérifier si cela ne provoque pas des effets de bords à l'affichage

Ressources

Autre exemple

L'affichage est géré à l'intérieur du composant

image

Note

In Angular, it is generally better to condition rendering in the child components rather than the parent component. This is because Angular is built on the principle of component-based architecture, where each component is responsible for its own rendering and functionality.

When you condition rendering in the parent component, it can lead to unnecessary re-rendering of child components that don't need to be updated. This can cause performance issues, especially in larger applications. By conditionally rendering in the child components, you can reduce the amount of unnecessary rendering and improve the overall performance of your application.

Additionally, by conditioning rendering in the child components, you can create more reusable components that can be used in different contexts. This allows you to write more modular code and makes it easier to maintain and update your application over time.

Edited by Ghost User