Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Route Parameters AngularJS

Posted on 2014-09-22
3
Medium Priority
?
480 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 83

Accepted Solution

by:
leakim971 earned 2000 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 83

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

926 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