angular.module("errorStatusCheck", []) .service('errorStatusCheck', function() { this.checkErrorStatus =function (data,status,message) { if (status==401){ window.location.replace('/webapp'); } else if (message) { alert(message); } } });