Home > Blockchain >  Angular Generating New Page Routes (and pages) Dynamically
Angular Generating New Page Routes (and pages) Dynamically

Time:08-16

I am still getting used to this concept of single page application. I have an old jsp form application that has multiple pages. The number of pages it has is determined on what a user selects in the UI (dynamically creating more webpages). I am trying to rewrite it in angular 13

I was wondering if there is a way to do something similar. I know that I can set the routes the my app.routes.ts, but what if we don't know how many routes (or webpage urls) there will be in the beginning of the app? and I want to create new routes (and pages) on the fly like the jsp app which is determined by user input? I will just use a bunch of generic components to populate the pages of these new routes.

Does this also go in contradiction to the SPA ideas?

CodePudding user response:

based on what i understood, you have lots of pages with the same behavior, and different content right? if its your case you need to do this.

1.create a component that reads id form route if you do not know how to do that read angular router document(you can find in in google)

2.config your routes and test it

  1. create a service and config it to provide your content based on id that u get from route then load the content in that component

CodePudding user response:

I have also been thinking of using a tabbed interface instead of having many pages so everything kinda stays on a "single page". I am also thinking the number of tabs could get messy if there are a lot of them. The idea would be to add a new tab based on what the user selects.

CodePudding user response:

Well it seems that your question has two dimensions: UI and Logic.

1- How you will define your UI that's your personal choice. But there are multiple options (patterns) to go with. Check Angular Material Components for example on how to organise your web app.

2-Yes you can have dynamic parts in your application URL. Angular allows you to define dynamic segments based on user navigation. Please read more on common routing tasks on the Angular documentation

  • Related