Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we create multiple components with same name in angular 2?

I am creating a v2 for my UI. I want to keep the old UI and make changes. So I was thinking of keeping the name of new component same as old one.

So it is possible to have 2 different component with same name?

like image 423
Bishesh Acharya Avatar asked Mar 07 '23 06:03

Bishesh Acharya


1 Answers

What you could do is have two Classes one old and one new, with semantic naming rather than new and old of course, and within the master component class, have the logic for switching between the two.

or you could import as Alias, which means both classes can be the same name but where you use it obviously has to be different:

import { MyComponent as OldComponent } from '../old/my-component'
import { MyComponent} from '../new/my-component'
like image 83
cjonasw Avatar answered Mar 20 '23 04:03

cjonasw