AngularJS directives for jQuery Mobile


Added by: Sam Deering





Stars: 346

Watchers: 346

Forks: 69

Module Description

Build Status #Angular-JQM

Update Feb 2014: This project is currently not under development. If you wish to take it up and finish it (angular-1.2 branch is nearly ready), please email [email protected]

This project has not been released yet. It is still in alpha stage, but it is usable in an app if you are willing to face a few API changes here and there.

  • Docs:
  • Extensive Demo: Coming soon

##Description Native AngularJS directives for jQuery Mobile. Small footprint, no 3rd party JS dependencies (jQuery, jQuery Mobile JS) required!


  • Download size: If you want to use the JavaScript part of jqm, you also need to use jquery. In total you need angular, jquery, jqm and the adapter. A lot of stuff...
  • Performance: The original jqm widgets not always do things the most performant way. E.g. they use a lot of css selector queries. Furthermore, they usually only have one refresh method to refresh to whole widget (e.g. a listview), but not parts of it.
  • Maintainability: Using the jqm JavaScript part requires some dirty hacks so that it works with angular. However, to maintain those hacks you need a lot of knowledge about the internas of jqm and angular.

This is very similar to the angular bootstrap integration: There is an adapter that uses the JavaScript part of bootstrap, angular-strap (, and another version that uses the boostrap css only from the angular-ui team (

To ensure that our directives work correctly we create special tests that compare the generated markup of our directives with the markup generated by plain jquery mobile. By this it should also be easy to keep track of changes in jquery mobile when they release newer versions.



Directory structure

  • dist: The compiled versions of the adapter (ignored during branch merges).
  • src: The source files of the adapter
  • test/unit: The unit tests


  • Commit messages must follow the conventions here. This is checked using a pre-commit hook in git, which gets installed after the first call to grunt.


  • Install the dependencies: npm install and then grunt install
  • Build it: grunt
  • Auto-Run tests when file change: grunt dev

(this needs grunt-cli installed globally: npm install grunt-cli -g)


  • for all source files we have unit tests

  • for all directives, we additionally have tests that compare the markup with the real jqm widgets (see testutils.js#compareElementRecursive).

  • unit tests may access every private function in jqm-angular:

    For the whole build, we are using an immediately executing function expression to ensure that no variable leaks into the global scope. However, when running the unit tests we include the source files without that protection. Note: The same principle is used by angular for it's sources and unit tests.

Getting started

Your main html file should look like this:

<!DOCTYPE html>
<html ng-app="app">
    <link type="text/css" rel="stylesheet" href="">
    <script src="angular.js"></script>
    <script src="angular-mobile.js"></script>
    <script src="angular-jqm.js"></script>
    <!-- include your application script files here -->
    <script src="app.js"></script>

<body jqm-caching-view>



Inside your application scripts, define a new module that depends on the module jqm and setup routes for all pages that you want to display. E.g.:

var mod = angular.module('app', ['jqm']);
mod.config(function($routeProvider) {
    // A route for a single page
    $routeProvider.when("/", {
        redirectTo: "main.html"
    // A route for all pages in one folder
    $routeProvider.when("/:page", {
        animation: 'page-slide',
        templateUrl: function(params) {


We already set up pages to play with during development and compare your directive with jquery mobile. For this, first do a grunt dev. Then visit one of the following pages:

Module stats last updated: 2018-01-13 16:00:02

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!