Skip to content

Instantly share code, notes, and snippets.

@benoitboucart
Created February 4, 2014 19:19
Show Gist options
  • Save benoitboucart/8810383 to your computer and use it in GitHub Desktop.
Save benoitboucart/8810383 to your computer and use it in GitHub Desktop.
Feature detection with AngularJS en Modernizr
// Going mobile with Angular by Ari
// Source: https://speakerdeck.com/auser/going-mobile-with-angular?utm_source=ng-newsletter&utm_campaign=b5794c7e19-AngularJS_Newsletter_2_4_142_3_2014&utm_medium=email&utm_term=0_fa61364f13-b5794c7e19-96511737
angular.module('alTouchDevice', [])
.provider('TouchDevice', function(){
var deviceType = false;
this.setToucheDevice = function(t){
deviceType = true;
};
this.$get = function() {
return deviceType
};
})
;
// Usage
angular.module('myApp')
.config(function(TouchDeviceProvider) {
if(Modernizr.touch) {
TouchDeviceProvider.setTouchDevice();
}
})
;
@ptitb
Copy link

ptitb commented Jul 30, 2014

this.setToucheDevice should be this.setTouchDevice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment