Hybrid Mobile App Development with PhoneGap, AngularJS and Bootstrap

By | May 8, 2015
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest

Thanks to the easy availability of brilliant Mobile Application Development frameworks, it has become quite comfortable to come up with remarkable hybrid mobile apps that look great and function in the desired manner. Nowadays, web developers are trying their hands on combining multiple frameworks in order to arrive at an architecture that can serve as the ground base for development of fantastic mobile apps. One such combination that has been embraced by several web developers is that of PhoneGap, AngularJS and Bootstrap.

Hybrid Mobile App Development

Today, through this post, I’ll be offering you a step wise guideline on using this perfect combination for building commendable hybrid mobile apps.Mobile App using PhoneGap

A closer look at the hybrid mobile app architecture with AngularJS, PhoneGap and Bootstrap

Talking about the architecture built using the combination of PhoneGap, AngularJS and Bootstrap, I would like to put forwards that the presentation layer is being created using the Bootstrap framework (getting started with Bootstrap Tutorial), the app logic/domain is being modeled using AngularJS (getting started with AngularJs Tutorial). This app domain/logic is being further packaged using PhoneGap/Cordova to a native mobile application.
Now, let’s have a look at the different steps associated with creation of a hybrid mobile application using a combination of AngularJS, PhoneGap and Bootstrap.

Step 1- Build an initial app template

Here, you can use the PhoneGap/Cordova CLI. All you need to do is simply execute the below command:

phonegap create appExample com.neojack.appExample AppExample

The above ‘create’ command would require the following three arguments:

  • Firstly, there is a directory name which is required for generation of project. Here, it is “appExample”
  • Secondly, there is a project identifier. Here, it is “com.neojack.appExample”
  • Thirdly, there is a display title of the application. Here, it is “AppExample”

Step 2- Download and install Geolocation plugin

The hybrid mobile app that we are going to build in this tutorial will display current location coordinates and hence for reading these coordinated, it is necessary to install the Geolocation plugin. You can do the same by running the below command:

cordova plugin add org.apache.cordova.geolocation

Step 3- Incorporate the platform to which you want to deploy the mobile application

Here, just go to the app directory i.e. appExample and run the below command for adding iOS as the mobile platform:

phonegap platform add ios

Next, build the example app by running the below command:
phonegap build ios

Do note you can repeat this step for a mobile platform of your choice such as BlackBerry, Android, Windows Phone etc.

Bootstrap is the world’s most popular mobile ready web development framework for HTML, CSS and JavaScript. Bootstrap is for you if you want to quickly build a super cool website which work across devices and browsers. It is easy to learn and super powerful.
Learn Bootstrap by Example

Step 4- Add the Bootstrap and AngularJS files to the mobile app created in the step 3

After having set the mobile platform for the app, just add the Bootstrap(bootstrap.min.css and bootstrap-theme.min.css into appExample/www/css directory) and AngularJS files(angular.min.js, angular-route.min.js etc. to appExample/www/js directory). Now, link all these files to main.html file by adding the below mentioned CSS code the head section:

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css"/>
<link rel="stylesheet" type="text/css" href="css/index.css" />

Code associated with linking the Javascript files is shown below:

<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/angular-route.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>

Step 5- Now, code the application’s logic

You’ll require angular route config, view and an angular controller for coding the app logic. Code snippet for app.js file is shown below:AngularJS Code

In the above code, I’ve defined angular app and named it as appExample. After that I’ve initated it and defined the ngRoute and ui.bootstrap modules. Also, you can find the onDeviceReady event which is being fired each time the mobile app is loaded. Within this event, the current position of the device can be fetched via a single line of code similar to one displayed below:

navigator.geolocation.getCurrentPosition(app.onSuccess, app.onErr);

In the above code, getCurrentPosition function requires two additional functions viz: one which is called when the current location has been obtained successfully and other one which is called when the current location of device isn’t available.

Displayed below is the success function which will be used for reading the coordinated and binding the same to the angular app i.e. appExample:AngularJS App

Step 6- Define the two views for the hybrid mobile application

Here, you need to define two app views, one for page and other for showcasing location details. Below is the function used for displaying coordinates within the view:

<p class="text-center"> Your location is: <br/>
Latitude: {{latitude}}<br/>
Longitude: {{longitude}} <br/>
</p>

Step 7- Connect the coordinates to view via a controller

The structure of controller will be like this:

appExample.controller('mainController', function($scope, $route){
$scope.latitude = appExample.latitude;
$scope.longitude = appExample.longitude;
});

Step 8- Bind the controller to view via addition of router configuration

The code snippet for the router is shown below:Bind Controller to View

In the above code, router part will define a default url and ‘/about’ url. The former part would bind to main.html view while the latter one would bind to about.html view.

Step 9- Add reference for created files in index.html file

Here is how the references for last created files look like:Hybrid Mobile App

That’s it about developing a hybrid mobile app. Now, you must deploy it to your device for testing purpose. For this, you can either opt for a real device or a simulator.

You are developing a customer web form that includes the following HTML.

<input id=”txtValue”/>

You need to change the HTML markup so that customers can enter only a valid three-letter country
code. Which HTML should you use?

  • A. <input id=”txtValue” type=”country”/>
  • B. <input id=”txtValue” type=”text” required=”xxx”/>
  • C. <input id=”txtValue” type=”text” pattern-” [A-Za-z] {3} “/>
  • D. <input id=”txtValuen type=”code” pattern”=”country”/>

For a complete HTML5 online test and Practice Exams, Click Here.

 Correct Answer: C

Final Words

Combining AngularJS, Bootstrap and PhoneGap in the above explained manner will undoubtedly allow you to come up with stunning hybrid apps that perform excellently on multiple hand-held devices.

Author Bio

Victoria Brinsley is a mobile app programmer for Appsted Ltd – a reputed Android development company. In case, you are willing to avail a detailed information on the same, get in touch.


HTML5 Web/Mobile Developer Jobs [Updated Daily]

Recents HTML5 Jobs

Front End Web Developer - Angular NINJA
Source: Indeed
Details: HTML5, JavaScript, CSS3, RESTful API web services, Bootstrap, Angular.js. Over and above anything else, here's the kind of person we want:....  More
25 days ago

Kirkland, WA 98033 28-February-2017

Front End Developer (Sharepoint and MWF)
Source: Indeed
Details: Proven track record of developing and implementing responsive web experiences using jQuery, Backbone.js, node.js, WinJS, JSON, HTML5 and CSS....  More
18 days ago

Redmond, WA 07-March-2017

Front End Web Developer
Source: Indeed
Details: Gulp, NPM, Bower)• Experience with RESTful web services, AJAX, JSON, AngularJS $resource• Advanced knowledge of HTML5, Bootstrap, CSS3• Experience with Sass CSS...  More
19 hours ago

Shelton, CT 24-March-2017

Web Design Front End Developer
Source: Indeed
Details: Strong knowledge of code (PHP, HTML5, CSS3, JavaScript, jQuery, etc.), and browser compatibility. Is looking for a passionate, experienced *Web Designer*....  More
2 days ago

Menomonee Falls, WI 53051 22-March-2017

Front End Web Developer
Source: Indeed
Details: Minimum 6+ years hands on front-end programming experience using HTML5, CSS3, JavaScript, JQuery, Angular JS, React JS, or similar frameworks....  More
2 days ago

Morrisville, NC 22-March-2017

PHP Web Developer w/Front-End Skills
Source: Indeed
Details: You're someone with 2+ years of experience in web development who lives and breathes - PHP/MySQL - HTML5 - CSS3 - Javascript/JQuery....  More
3 days ago

Atlanta, GA 21-March-2017

Front End Web Developer
Source: Indeed
Details: Javascript, jQuery, Angular, Graphing Libraries such Highcharts, D3.js), HTML5, CSS3, Bootstrap3, Responsive design, Cross browser compatibility,....  More
3 days ago

Troy, MI 48084 21-March-2017

Web Developer (Front End Web Dev/UI Dev)
Source: Nutrabolt
Details: Possesses strong technical and design skills including HTML5, CSS3, Javascript. Reporting to the SVP, Global Consumer Direct, the Front End Developer is...  More
6 days ago

Austin, TX 19-March-2017

Front End Developer
Source: Indeed
Details: Utilize latest HTML5, CSS, and JS techniques to produce highly-performant, informative, and beautiful user experiences for clients....  More
30+ days ago

New York, NY 10018 14-February-2017

Front-End Developer
Source: WETA
Details: Expert knowledge and proficiency in HTML5, CSS required. Work with the digital team to design and build PBS NewsHour products and contribute to the overall...  More
10 hours ago

Arlington, VA 22206 25-March-2017

Front End Developer
Source: Indeed
Details: *Front End Developer* We are currently looking to hire a Front End Developer The Front End Developer needs to be someone who can utilize HTML, CSS, and  More
13 hours ago

Roswell, GA 24-March-2017

UI Front End Developer
Source: Indeed
Details: Knowledge of HTML / HTML5 / CSS3 and frameworks such as Bootstrap or Foundation. We have a fast growing client that needs to add 3 Front-End developers!...  More
15 hours ago

Dallas, TX 24-March-2017

Front End Web Developer
Source: Indeed
Details: Experience with HTML5, CSS3, and common CSS preprocessors and frameworks. There is this magical recent invention called the "video game."....  More
6 days ago

Washington, DC 20001 18-March-2017

Front End Developer-REACT- NYC
Source: Indeed
Details: You should have experience working with REACT, Node, JavaScript, Mongo, HTML5, CSS3, Bootstrap, and Angular JS....  More
18 hours ago

New York, NY 10018 24-March-2017

FullStack Front End JavaScript Developer
Source: BlueLight Technologie
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
18 hours ago

Pittsburgh, PA 24-March-2017

FullStack Front End JavaScript Developer
Source: BlueLight Technologie
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
18 hours ago

Jersey City, NJ 24-March-2017

FullStack Front End JavaScript Developer
Source: BlueLight Technologie
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
17 hours ago

Orlando, FL 24-March-2017

FullStack Front End JavaScript Developer
Source: Indeed
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
23 hours ago

Pittsburgh, PA 24-March-2017

FullStack Front End JavaScript Developer
Source: Indeed
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
23 hours ago

Orlando, FL 24-March-2017

FullStack Front End JavaScript Developer
Source: Indeed
Details: JavaScript, HTML5, JQuery, CSS, ReactJS). Exciting Contract to Perm Role with American Express, this role is located in NYC, lower manhattan headquarters BS...  More
1 day ago

Jersey City, NJ 24-March-2017

UI/Back-End Developer
Source: Indeed
Details: Experience developing rich applications with HTML5, CSS and JS. 2+ year of professional frontend web software development with HTML5, CSS, Javascript, DOM, JSON...  More
22 days ago

Bellevue, WA 03-March-2017

Front End Developer
Source: Indeed
Details: Experience with ES6, JavaScript, HTML5, SASS or LESS, and CSS. Kimetrica is a social enterprise on a mission to increase the effectiveness of spending in the...  More
1 day ago

Washington, DC 23-March-2017

Front End Developer
Source: Indeed
Details: Strong skills in HTML5. RSG Media Systems develops advanced analytics solutions for major media and entertainment industry clients and other intellectual...  More
1 day ago

New York, NY 23-March-2017

Front End Web Applications Developer
Source: Knowledge Anywhere
Details: Proficient in technologies such as HTML5, CSS3, XML, JSON, AngularJS, Bootstrap, and JQuery. Knowledge Anywhere is an industry leading developer of corporate...  More
30+ days ago

Bellevue, WA 98004 22-February-2017

Front-End Web Developer
Source: DNTG Software
Details: Working at the corporate office, the developer will be responsible for all front-end development for our client's new e-commerce website launching this year.  More
8 days ago

Buena Park, CA 17-March-2017

Top 10 Interview Questions and Answers Series:

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest