Reputation: 31
I am new in angularjs and i want to create client side error/ exception logger (.log/ .js) file to server by using only angularjs. I do not want to use jquery.
Any help will be apprreciable
Upvotes: 2
Views: 1891
Reputation: 8184
In angularJS you log with $log
angular.module('logExample', [])
.controller('LogController', ['$scope', '$log', function($scope, $log) {
$scope.$log = $log;
$scope.message = 'Hello World!';
}]);
As far as I know, you won't be able to write in a file on the server without writing server side code. To send local log to server, use $http
as follows
$http({ url: "log/logExample.txt",
method: "PUT",
params: angular.toJson({
url: $window.location.href,
message: 'hello world',
type: "debug"
})
});
Upvotes: 2