Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between Angular app-routing.module.ts and app.routes.ts

Tags:

angular

I need to know the difference between Angular app-routing.module.ts and app.routes.ts and any best practices. I am using Angular latest. 17.0.10.

like image 734
MJ X Avatar asked May 28 '26 20:05

MJ X


2 Answers

Routing module requires a list of routes in its' configuration. We could just inline this potentially very long list of routes in same file, or we could move list of routes to const routes in separate file, to not have a long list in the middle of file with routing and other logic. Moving routes to separate file makes reading file with routing logic easier

like image 191
Ivan Ivanyuk Avatar answered May 31 '26 09:05

Ivan Ivanyuk


Both serves for similar purpose, configuring routes.In angular 17+ version the usage of app.route.ts is introduced. In previous versions of angular app.routing.module.ts is used.

like image 21
akhil Avatar answered May 31 '26 10:05

akhil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!