Detect OS, browser and device in AngularJS

In this lesson we will see how we can gracefully detect the Operating System, browser and device used by our user to browse our website.

Detecting browser is usually a bad smell and means that you are getting your hands dirty, however there are genuine cases where this can’t be avoided.
Detecting OS can be sometimes very important for example, if you are providing a download package or a software to your users, you would want to point them to the appropriate version depending on the OS.

Usually detecting these entities involves a bit of dirty JavaScript work, matching regex etc. but here we will be using an AngularJS library known as “ng-device-detector”, which will reduce our work significantly. It will tell us the os version and the browser version as well.