Created
February 4, 2014 19:19
-
-
Save benoitboucart/8810383 to your computer and use it in GitHub Desktop.
Feature detection with AngularJS en Modernizr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
}) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.setToucheDevice should be this.setTouchDevice