What is $location service in AngularJS
What is $location service in AngularJS
290
15-May-2024
Updated on 15-May-2024
Ashutosh Kumar Verma
15-May-2024$location Provides methods and properties for browser location manipulation. The $location service is passed to the controller as an argument. To use a service in a controller, it must be defined as a dependency.
You can use the window.location property to find the location of the webpage but it has some limitations in Angular applications, so using the $location service is the best option for Angular applications.
Example-
Output-
I hope you have understood how to use $location service in AngularJS application.
Thank you!