Angular JS Services Tutorial | Services in Angular Js | Angular JS Tutorials | #13

Опубликовано: 28 Сентябрь 2024
на канале: Shs Tech Solutions
59
3

#angularjs #angularjsservices #servicesin angular
AngularJS Services Tutorial - #13
In AngularJS you can make your own service, or use one of the many built-in services.
What is a Service?
In AngularJS, a service is a function, or object, that is available for, and limited to, your AngularJS application.

AngularJS has about 30 built-in services. One of them is the $location service.

The $location service has methods which return information about the location of the current web page

Note that the $location service is passed into the controller as an argument. In order to use the service in the controller, it must be defined as a dependency.

Why use Services?

For many services, like the $location service, it seems like you could use objects that are already in the DOM, like the window. location object and you could, but it would have some limitations, at least for your AngularJS application.

AngularJS constantly supervises your application, and for it to handle changes and events properly, AngularJS prefers that you use the $location service instead of the window. location object
Please Follow me on social media:
Facebook:   / shstechsolutions  
Twitter:   / shstechsolution  
Linkedin:  / moulali-shaik-59b441106  
Tumblr: https://www.tumblr.com/blog/cinenews