Angularjs Examples

AJS Examples

AngularJS $log Service

The AngularJS $log service is used to write error, info, warning and debugging into the browser's console. The $log service is used to simple simplify debugging and troubleshooting. It includes all the methods to log the error, information, warning and debug information.


$log.log('Log Message.');
$log.error('Log Error.');
$'Log Info.');
$log.warn('Log Warning.');
$log.debug('Log Debugging.');

AngularJS $log Service Example

<!DOCTYPE html>
<head> <!-- -->
 <script src="//"></script> 
    <meta charset="utf-8">
    <title>AngularJS $log Example</title>
var app = angular.module('app', []);
    app.controller("LogController", function ($scope,$log) {

      $scope.LogMessage = function()
      $scope.LogError = function()
      $scope.logInfo = function()
      $scope.logWarning = function()
      $scope.logDebug = function()
<body style="background-color:#DDE4E9;">
  <fieldset style="background-color:#DDE4E9;">            
    <legend>AngulerJS $log Service Example</legend> 
  <div ng-app="app">      
    <div ng-controller="LogController"> 
      <p>Reload this page with open console, enter text and hit the log buttons</p>
      Log Message:        
        <input type="string" ng-model="message">        
        <button ng-click="LogMessage()">Log Message</button></br>     
      Log Error:      
        <input type="string" ng-model="error">        
        <button ng-click="LogError()">Log Error</button> </br>     
      Log Info:    
      <input type="string" ng-model="info">  
        <button ng-click="logInfo()">Log Info</button> </br>
    Log Warning:      
        <input type="string" ng-model="warning">        
        <button ng-click="logWarning()">Log Warning</button> </br>     
      Log Debug:    
    <input type="string" ng-model="debug">  
        <button ng-click="logDebug()">Log Debug</button> </br>
See Live Example