Coder Social home page Coder Social logo

ronnyhaase / angular-ismobile Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 4.0 18 KB

A Angular wrapper provider-service for isMobile (https://github.com/kaimallea/isMobile)

License: Creative Commons Zero v1.0 Universal

JavaScript 100.00%
angular angularjs mobile-detection ismobile adaptive

angular-ismobile's Introduction

angular-ismobile

Travis branch

A Angular wrapper provider-service for isMobile (https://github.com/kaimallea/isMobile).

By Ronny Haase, 2016. Licensed under CC0 1.0 Universal (CC0 1.0).

Introduction

This is a stupid provider-service (meaning it's also available in Angular's configuration phase) that provides a cloned instance of isMobile.

It sniffs the user agent for mobile browsers, what you usually shouldn't need to do (responsive design, etc.), but it's a real world, isn't it?

See isMobile, to get more details on what and how it exactly works, and what will be returned by the service.

Important notice: The distributed version already includes isMobile.js!

Installation

Use npm:

$ npm install angular-ismobile

Or Bower:

$ bower install angular-ismobile

Or grab the latest release and add the JS file manually.

<script src="angular-ismobile.js"></script>

Or minified:

<script src="angular-ismobile.min.js"></script>

Important notice: The distributed version already includes isMobile.js!

Usage

As mentioned in the Introduction, the service simply returns a clone of the isMobile object. See isMobile, for details and reference.

// Add angular-ismobile module to your own module
angule.module('myApp', ['ismobile']);

// Inside a config-block, you inject the provider
angular.module('myApp').config(['$routeProvider', 'isMobileProvider',
	function ($routeProvider, isMobile) {
		if (isMobile.phone) {
			$location.path('/mobile');
		}

		$routeProvider.when('/mobile', {
			// ...
		});

		// ...
	}]);

// At runtime (run-block, controllers, anywhere), you inject the service instance
angular.module('myApp').controller('someController', ['isMobile', function(isMobile) {
	if (isMobile.phone) {
		// ...
	}
}]);

Contributing

Please create an issue. If you add a pull request, try to respect my code style, check for JSHint and assure the unit tests do pass, and extend them if necessary!

angular-ismobile's People

Contributors

ronnyhaase avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

angular-ismobile's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.