Solved

Route Parameters AngularJS

Posted on 2014-09-22
3
458 Views
Last Modified: 2014-09-23
As I am learning AngularJS, I came to know about that we can embed parameters into the route path.

So the web page will look like      localhost/#/books/12345.

I know it is making my life easy in coding as I can go to 5-6 screens easily by giving parameter in URL.

Is it a good practice to show ID=12345 in a web page? Let me know the advantages or disadvantages, if any?
0
Comment
Question by:rbhargaw
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40337715
I think it's all about Search Engine Optimization
You can use both.
The main difference between query-string (?) and path(/) parameters.
there's no order with query-string : ?id=10&name=beef same as ?name=beef&id=10
where the order is important with path parameters, route is not the same using :
/name/beef/id/10

so use a path parameter to define your angualr route and optionnaly, if needed, query string parameter

don't forget to take a look to the ui-router project, I'm 99% you are going to move to this router instead the ng-route (whihc is now in a separate file as your know)
0
 

Author Comment

by:rbhargaw
ID: 40337800
Thanks for the info! Another question, I wanted to check if in  real app should the user see that he made a search with id/10 or whatever number. My concern is if I can go to a page using id/10, anyone would be able to go to that data using id/10. How do I control that only specific user can request this information?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40337823
no, you made a request to the server for the view, it check user session, if it found a valid session it send back the view/data else it fail and your throw the error with angular to display an appropriate page
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question