Tuesday, 21 March 2017

How to use $log service ?


$log is a built-in service that can be used to log the message in Web browser console.
  1. Inject the service in controller function
  2. Use $log.info function to log the messages

app.controller("myController", function ($scope, $http, $log) {
   $http( { 

       method: 'GET',
       url:'EmployeeService/GetAllEmployees' })
   .then( function(response) {
       $scope.employees = response.data;

       $log.info(response);
   });
});


Logs can be checked using Developer tools.
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.