JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.js"></script>
<div ng-app="myApp" ng-controller="DoctorsController as doctorsController"></div>
JavaScript
angular.module('myApp', []);
angular.module('myApp').service('WebServiceFactory', function ($http) {
var WebServiceFactory = this;
WebServiceFactory.getData = function (url) {
return $http.get(url, {timeout: 10}); // timeout of only 2 MILLISECONDS
}
return WebServiceFactory;
});
angular.module('myApp').controller('DoctorsController', function (WebServiceFactory) {
var url = '/echo/json';
WebServiceFactory.getData(url)
.then(function () {
console.log('success');
}, function () {
console.log('failure by timeout');
});
});