My question is fairly simple: how should I organize my code so as to make my component(s) autonomous and customizable?
At the moment I can come up with two major approaches:
1) Pass props with customization params through @Input()'s
2) Compose components from smaller parts using @ContentChildren()
E.g.: I need an ability to create different types of dialogs:
1) notification (title?, text, ok-label, ok-action)
2) confirmation (title?, text, cancel-label, cancel-action, ok-label, ok-action)
3) complex-dialog (title?, text | component | template ref, custom buttons' labels & actions)
I'm going to create a dialog service, which can open dialogs (via MatDialog) using only one customizable Dialog component. Tell me please if whether I'm right or wrong and why.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire