Changing API usage from $http to $resource