Trending News
Home / Web Development / Angular Js / AngularJS – Services

AngularJS – Services

The service will helps to fetch data from the database when to share the data between controllers.
If we store the data inside a controller, once we change to another controller the data will be discarded.
AngularJS has 30 built in services.

Types of Services in AngularJS

  1. Built-in Services: The angularjs has inbuilt services. That’s is core services.
    The built in services like $http, $log, $location etc..
    The inbuilt services are always prefixed with $.
  2. Custom Services: These services are developed by developers to achieve certain business logic in the form of service.

The $http Service

The $http is the one of the inbult services in angularjs. It is commonly used services in angularjs application.

Example

Use the $http service to request data from the server:

From the above code we can clearly say that: The $http service requests a page on the server, and the response is set as the value of the “myWelcome” variable.

The $location Service

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

Example

Loading Facebook Comments ...
Social Media Auto Publish Powered By : XYZScripts.com