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.

Angular 4 is out now. We can use Angular 4 to develop applications that are cross platform with maximum speed and performance. More to learn Angular 4 here.

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

PHP Web Developer- Seattle WA
Source: Advanced Computer Learning Company, LLC (ACLC)
Details: Expert front end web developer with deep knowledge of HTML5, CSS3 and Javascript/Frameworks. PHP Web Developer....  More
30+ days ago

Seattle, WA 98101 10-August-2017

Front End Developer
Source: Indeed
Details: HTML5 -CSS -JavaScript -Ionic / Cordova -XCode / Android IDE -Web services API integration. Grooters Productions’ Development Team builds cutting-edge digital...  More
1 day ago

Holland, MI 49423 17-October-2017

Front-End Developer
Source: Indeed
Details: Strong knowledge of and ability to code custom, semantic HTML5 and custom CSS3 (without frameworks like Bootstrap)....  More
1 day ago

Dallas, TX 75202 16-October-2017

Front-End Developer
Source: Indeed
Details: Proficient understanding of web markup, including HTML5, CSS3. We are seeking a talented Front-End Developer to take ownership of the front-end development and...  More
1 day ago

Ridgefield Park, NJ 16-October-2017

Front End Developer
Source: Indeed
Details: Knowledge on Ruby/Java/C++ is plus- Expert knowledge in MYSQL and other database technologies.- Knowledge and experience on data analysis, MongoDB database is a...  More
4 days ago

West Chester, PA 13-October-2017

Front-End Developer
Source: Indeed
Details: Expert skills in writing hand-coded HTML5, CSS3 and JavaScript. Kalidy is currently hiring a Front-End Developer to add to our team....  More
4 days ago

Edmond, OK 73013 13-October-2017

Freelance Front End Developer/Designer
Source: Indeed
Details: Manages usability testing based on prototypes of wireframes and creative• Stay current with core web development technology trends, capabilities, and...  More
4 days ago

Delray Beach, FL 33483 13-October-2017

Front End Developer Intern
Source: Indeed
Details: Proficient understanding of web markup, including HTML5, CSS3. About the Company*....  More
5 days ago

Playa Vista, CA 13-October-2017

Front End Developer
Source: Indeed
Details: Experience building software using VueJS, NodeJS, JavaScript, JQuery, HTML5, CSS, JSON, XML, AngularJs, Backbone & Polymer. Front End Developer....  More
5 days ago

San Ramon, CA 12-October-2017

Front End Developer
Source: Indeed
Details: Proficient understanding of front-end markup, including HTML5 and CSS3. Indeed Hire is in partnership with StraightLine HDD to find a skilled FED....  More
6 days ago

Wichita, KS 11-October-2017

Front-End Developer
Source: Indeed
Details: HTML5, CSS3, LESS, SASS, Bootstrap-3, JavaScript, Typescript, JQuery, Angular.js, Node.js, Require.js, Knockout.js, Hammer.js, ajax, Firebug, Chrome Developer...  More
6 days ago

Pella, IA 11-October-2017

Front End Developer
Source: Indeed
Details: Proficient in markup coding by hand, specifically HTML5 and/or XHTML 1.0. Demonstrated experience producing and delivering final assets using HTML5, CSS3, JSP...  More
30+ days ago

Dallas, TX 14-September-2017

Front End Developer
Source: Indeed
Details: Experience in HTML5, CSS3, jQuery, Spring, JSF, AJAX, JavaScript, ASP.NET, nwjs, git, mysql. Front End Developer....  More
6 days ago

Philadelphia, PA 11-October-2017

Front End Developer
Source: Indeed
Details: Proficiency with HTML5, JQuery, JavaScript. Front End Developer – Full Time....  More
7 days ago

Indianapolis, IN 46220 10-October-2017

Front End Developer
Source: Indeed
Details: Deep understanding of HTML5, CSS3 and cross-browser compatibility. Data Sciences, Surveys, and Enabling Technologies (DSET) is Abt’s full-service technology,...  More
7 days ago

Bethesda, MD 20814 10-October-2017

Front-End Developer
Source: Indeed
Details: Ability to write standards-compliant and cross-browser compatible HTML5 and CSS3 from scratch. Our ideal candidate is a resourceful problem-solver with...  More
8 days ago

Chicago, IL 60654 09-October-2017

Angular Front End Developer
Source: Indeed
Details: Demonstrated knowledge of HTML5, JavaScript/TypeScript, CSS and Angular V2/V4 development is an absolute must. Angular Front End Developer*....  More
8 days ago

San Diego, CA 09-October-2017

Front-End Developer
Source: Indeed
Details: Expert knowledge of HTML5 and CSS3 and JavaScript. About the Company:....  More
11 days ago

Ann Arbor, MI 06-October-2017

#6814 - User Experience Front End Developer - Need locals to GA
Source: Indeed
Details: Demonstrated ability with HTML5, CSS, SASS, JavaScript, AJAX, and Web Services. Looking for User Experience Front End Developer for one of our client in Atlanta...  More
11 days ago

Atlanta, GA 06-October-2017

Front End Developer
Source: Indeed
Details: *Indeed Hire is in Partnership with Softvision.* *Front-end: * We are looking for an exceptional Senior Frontend Designer/Developer to work with our cross...  More
11 days ago

New York, NY 06-October-2017

Front End Developer Gaming Company
Source: Indeed
Details: Mandatory: Advanced knowledge of JavaScript, HTML5, CSS3 technologies Knowledge of JS Framework: AngularJS 1.x Proficiency in the tools: git, grunt, bower...  More
12 days ago

Feasterville-Trevose, PA 19053 05-October-2017

Front-End Developer
Source: Indeed
Details: HTML5 and CSS2/3:. Develop new user interfaces using Javascript, CSS and HTML5. At least 2 years experience in Javascript frameworks, HTML5 and CSS2/3....  More
12 days ago

Oklahoma City, OK 05-October-2017

Front End Developer
Source: Indeed
Details: Fluent in JavaScript, HTML5, and CSS3. We are looking for an experienced front-end developer to join our team....  More
12 days ago

Tampa, FL 05-October-2017

Front End Developer
Source: Indeed
Details: Develop clean, semantic markup with current best practices utilizing HTML5, CSS3, and Javascript libraries. As a Front End Developer at Impreza, you’ll get work...  More
13 days ago

Phoenix, AZ 85031 04-October-2017

Front End Developer
Source: Indeed
Details: *Job Summary* Position Summary: The front-end developer will work alongside senior (full stack) developers and UI/UX designers to develop various projects....  More
15 days ago

Springfield, OH 02-October-2017

Top 10 Interview Questions and Answers Series:

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