<!DOCTYPE html>
<html  ng-app="viewerApp">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

    <title>Service Test</title>
</head>

<body ng-controller="viewerController">
<h3>Service Testing :</h3>
Use this Plunker with an eye on the console in order to test the CORS functionality on a webservice.<br /><br />
  
<table>
  <tr>
    <td>Username :</td>
    <td><input ng-model="username" /></td>
  </tr>
  <tr>
    <td>Password :</td>
    <td><input type="password" ng-model="password" /></td>
  </tr>
</table>
<br />
Service query URL : <br />
<textarea ng-model="queryURL" rows="4" style="width: 90%;"></textarea><br /><br />
<button ng-click="testService()">Test CORS</button>
<script src="viewerController.js"></script>

</body>
</html>
var app = angular.module('viewerApp', []);

app.controller('viewerController', function ($scope, $http) {

var cDate = new Date();
$scope.currentDate = cDate.getFullYear() + "-" + (cDate.getMonth() + 1) + "-" + cDate.getDate() + " " + cDate.getHours() + ":" + cDate.getMinutes() + ":" + cDate.getSeconds();
$scope.queryURL = 'http://smartservices-it.intramundi.com/smsit/api/queries/exec/getOpenedIncidentAtTimeByApp/?format=json&START_DATE=' + $scope.currentDate + '&END_DATE=' + $scope.currentDate + '&ITEM_STATUS_ID=1&ID_APPLI=0';

$scope.testService = function() {
  var token;
  if ($scope.username && $scope.password)
    token = btoa($scope.username + ':' + $scope.password);
  else
    token = "None. Please provide Username/Password."
  
  console.log("Token used with Basic Authorization :", token);
  $http({method: 'GET', url : $scope.queryURL, headers: {'Authorization': 'Basic ' + token}}).
          success(function(data, status, headers, config) {
              console.log(data);
          }).
          error(function() {
              console.log("An error occured.");
          });
    };
});