U
U
Urukhayy2018-06-26 11:45:33
Angular
Urukhayy, 2018-06-26 11:45:33

Should components be made abstract?

There is a component, in it tabs. I want the tab to switch automatically depending on what is in the URL after " / ". And I need such functionality with tabs in several modules. Can I copy logic between files and change the name of functions after copying, or is it better to make abstract components?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
ValeraValera, 2018-06-26
@Urukhayy

The whole point of components is that they need to be reused! If the same functionality occurs more than once in a project, move it to a Component or Module (if there are several components)! There are Input and Output decorators for this.
And it is better to use ready-made Tabs for this you need to google.
And so you walk with a bicycle in your hands)

S
Sergey, 2018-06-26
@Sergamers

And I need such functionality with tabs in several modules.

Create ShareModule and do exports, declarations of this component there.
And then import.
If you need to pull out part of the logic of a component and transfer it to another component, then you can use a class. If necessary, make an abstract class or interface.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question