What is the proper way to rename a component in angular? Is there a command in the CLI to do so, or should I do the renaming manually?
            Asked
            
        
        
            Active
            
        
            Viewed 2,835 times
        
    0
            
            
        - 
                    Is this still applicable today? Since the question was 4 years ago @YongShun – Osama Radwan Nov 02 '21 at 07:59
- 
                    3It seems there is still no official support from CLI to rename components. We have to do it manually wiz-a-wiz be at the IDE's mercy to rename all the imports. – Kanishk Anand Nov 02 '21 at 08:05
- 
                    1It still an open discussion about it : https://github.com/angular/angular-cli/issues/900 – Rebai Ahmed Nov 02 '21 at 09:33
1 Answers
0
            
            
        Particularly, It seems that there is still no official support from the Angular CLI to rename components. The only solution right know is doing the following:
- Rename all the files in the component folder
<new-name>.component.css,<new-name>.component.html,<new-name>.component.spec.ts,<new-name>.component.ts.
- Rename the paths to templateUrl and styleUrls under the @ComponentType Decorator in<new-name>.component.ts.
- Rename the Class name in <new-name>.component.ts.
- Modify the import of the component in and its declaration under the @NgModuledecorator in theapp.module.tsfile.
Edit No.1:
Check the answer of the link below:
How to rename a component in Angular CLI?
There is also an open discussion on Github regarding the same topic:
 
    
    
        Osama Radwan
        
- 521
- 1
- 5
- 17