AngularJs Change Url – Sometimes we need to change the url in angularjs. You can use $location.url to redirect from one page to another page. Here in this tutorial we are going to explain how you can redirect in angularjs. You can use our online editor to edit and run the code online.
AngularJs Change Url
You can change the current using the following syntax-
AngularJs Change Url Example:
|
$location.url(‘/User/’+userId); will set the current url to the new url example – www.example.com/User/98. You can call the function – changeUrl(userId) on button click.
Note : Make Sure the service $location is imported before using it.