Service with ---> Angular

app.service('Host', ['$http', function ($http){ this.doConnect = function(url){ return $http.get('http://'+url+':3001/handshake') .then(function(response) { if(response.data.status.toLowerCase() == 'ok') window.localStorage.setItem('host',url); return (response.data.status && response.data.status.toLowerCase() == 'ok'); }, function(err){ return false; }); } this.getUrl = function (){ return window.localStorage.getItem('host'); } return this; }]);

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.