Tuesday, June 16, 2015

AngularJS pre-defined services

AngularJS provides a set of pre-defined services, which can be used in any controller by referencing the services. All predefined services are pre-fixed with a $ symbol.

$http, $window, $routeProvider etc are some of the pre-defined services provided by AngularJS. To use these services in a controller we should refer to them while defining the controller, in the following controller example we shall use the $scope and $http service.

app.controller("BasicAppController", function($scope, $http) {
    $scope.message = "";
    $scope.Load  = function()
    {
          $http.get("http://localhost/...")
                   .then(function(results){
                             //Handle Success;
                                             $scope.message = “Success”;
                   }, function(results){
                             //Handle Error
                                             $scope.message = “Failure”;
                   })
          };
});

Search Flipkart Products:
Flipkart.com

No comments: