I have two different aspx pages which operate using AngularJS. One page is to add a post and on clicking save, I want to redirect to the detailpage.aspx. Can this be done using AngularJS?
3 Answers
You could always use plain javascript to make a redirect to another server side resource:
window.location.href = '/detailspage.aspx';
By the way, is there any point of having multiple ASPX pages when using AngularJS? Usually a SPA application has a single entry point and multiple REST API endpoints that will be called by this SPA application using asynchronous requests.
2 Comments
Yukti Arora
Thanks for your help. Using ASPX pages is a client requirement. Is there a way to read postID from the URL; example: /details/10. How do I read 10 from the URL in Angular?
Darin Dimitrov
This seems to be a server side URL. Angular only deals with client side urls: the part following the fragment (
#) identifier. If you want to use some server side parameters that are 2 possible approaches: Have the server script pass this parameter to the SPA application or use window.location.href (which will give you the current url) and parse it manually in Angular. It looks like due to your client's requirements you are violating some important patterns of a SPA application which will lead you to all kind of troubles. It's just against the nature of a SPA application.