Utility.js

angular.module('homepage').
service('BrowserType', function($window) {
	return function() {
		var userAgent = $window.navigator.userAgent;
		var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer/i};
		for(var key in browsers) {
			if (browsers[key].test(userAgent)) {
				return key;
			}
		};
		return 'unknown';
	}
}).
service('MobileType', function () {
	return {
		Android: function() {
			return navigator.userAgent.match(/Android/i);
		},
		BlackBerry: function() {
			return navigator.userAgent.match(/BlackBerry/i);
		},
		iOS: function() {
			return navigator.userAgent.match(/iPhone|iPad|iPod/i);
		},
		Opera: function() {
			return navigator.userAgent.match(/Opera Mini/i);
		},
		Windows: function() {
			return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
		},
		any: function() {
			// TODO make width as 480
			var isWidthLessThanDesktop = window.innerWidth < 600;
			return (this.Android() || this.BlackBerry() || this.iOS() || this.Opera() || this.Windows() || isWidthLessThanDesktop);
		}
	};
});