AngularJs-$log-1

 

In AngularJS $log is used to display message in browser console and there are four type of log messages: a) error b) log c) warn d) info. Example will show all for type of log and these error will show in console window. You can open console by pressing F12 in google chrome. See the code snippet:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>WWelcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="$logController"> <input type="radio" ng-model="q" value="log" ng-click="log.log(message)">log <input type="radio" ng-model="q" value="warn" ng-click="log.warn(message)">warn <input type="radio" ng-model="q" value="info" ng-click="log.info(message)">info <input type="radio" ng-model="q" value="error" ng-click="log.error(message)">error <input type="radio" ng-model="q" value="debug" ng-click="log.debug(message)">debug </div> </body> </html> <script> var app = angular.module("app", []); app.controller('$logController', ['$scope', '$log', function ($scope, $log) { $scope.log = $log; $scope.message = 'LearnKode error in console'; }]); </script>
Output