var urlapi = "http://localhost:3000/api/"; angular.module('workApp', ['chart.js']) .controller('workController', function( $scope, $interval, $http ) { $scope.users={}; $scope.projects={}; $scope.currentInclude='login.html'; var refreshTime=20000; /* DASHBOARD initialization */ $scope.dashboardInit = function(){ if(localStorage.getItem('owt_token')){// adding token to the headers $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('owt_token'); $http.defaults.headers.post['Content-Type'] = 'application/json'; $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('owt_token'); } if(localStorage.getItem("owt_user")){ $scope.user=JSON.parse(localStorage.getItem("owt_user")); }else{ $scope.currentInclude="login.html"; } //getting users $http.get(urlapi + 'users') .success(function(data, status, headers,config){ if(data.success==false){ localStorage.removeItem("owt_token"); localStorage.removeItem("owt_user"); $scope.currentInclude="login.html"; console.log("token ended"); }else{ console.log(data); $scope.users=data; } }) .error(function(data, status, headers,config){ console.log("server not responding, data error"); toastr.error("server not responding"); $scope.$broadcast('scroll.refreshComplete');//refresher stop }) .then(function(result){ users = result.data; }); //getting projects $http.get(urlapi + 'projects') .success(function(data, status, headers,config){ if(data.success==false){ localStorage.removeItem("owt_token"); localStorage.removeItem("owt_user"); $scope.currentInclude="login.html"; console.log("token ended"); }else{ for(var i=0; i