Solved

Route Parameters AngularJS

Posted on 2014-09-22
3
455 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 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