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/>

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 Designer - 683571
Source: The Learning House
Details: CSS3, HTML5, JQuery, Wordpress, PHP, Photoshop. The Learning House, Inc....  More
11 days ago

Nashville, TN 04-December-2017

Front-End Web Designer - 683567
Source: The Learning House
Details: CSS3, HTML5, JQuery, Wordpress, PHP, Photoshop. The Learning House, Inc....  More
11 days ago

Cincinnati, OH 04-December-2017

Front-End Web Designer - 683577
Source: The Learning House
Details: CSS3, HTML5, JQuery, Wordpress, PHP, Photoshop. The Learning House, Inc....  More
11 days ago

Lexington, KY 04-December-2017

Front-End Web Designer - 683575
Source: The Learning House
Details: CSS3, HTML5, JQuery, Wordpress, PHP, Photoshop. The Learning House, Inc....  More
11 days ago

Indianapolis, IN 04-December-2017

Front-End Web Designer - 671832
Source: The Learning House
Details: CSS3, HTML5, JQuery, Wordpress, PHP, Photoshop. The Learning House, Inc....  More
30+ days ago

Louisville, KY 40202 09-November-2017

Front End Developer
Source: MediaPro
Details: This position requires a combination of programming skills (namely PHP, HTML5, CSS3, and JavaScript) and aesthetics (understanding element arrangements on the...  More
6 days ago

Bothell, WA 98011 09-December-2017

Web Developer
Source: Indeed
Details: Experience in HTML5 and CSS3- JavaScript experience. We are looking for an Website Developer to join our team!...  More
25 days ago

Irvine, CA 92614 21-November-2017

Web Developer
Source: Indeed
Details: *Job Summary* *Excel Health is a "startup" SAAS healthcare data analytics firm.* Started in 2015, Excel Health Home Healthcare and Hospice Market...  More
28 days ago

Philadelphia, PA 17-November-2017

Front-End Web Developer
Source: Indeed
Details: Proficient understanding of web markup, including HTML5, CSS3. Front-End Web Developer*....  More
30 days ago

Redmond, WA 98052 16-November-2017

Web Designer
Source: Abstrakt Marketing Group
Details: SCOPE OF ROLE: We are seeking someone who is excited to utilize both their artistic skills and their technical knowledge to create innovative designs for the...  More
21 hours ago

St. Louis, MO 15-December-2017

Front End Web Developer
Source: Loove Music
Details: 3+ years front end development experience including HTML5, CSS3, JavaScript, and Git. Front-End Web Developer....  More
2 days ago

Brooklyn, NY 13-December-2017

Front-End Web Developer
Source: Luxoft
Details: 5+ years of experience with HTML5, JavaScript, CSS/LESS/SASS, Angular/Knockout/React or other modern JavaScript frameworks....  More
7 days ago

Redmond, WA 08-December-2017

Web Developer: Front-End
Source: Indeed
Details: Bonus points for HTML5 animation skills. HTML, HTML5, CSS, CSS3, JavaScript, JQuery, PHP guru. FULL-TIME | SEATTLE, WA....  More
7 days ago

Seattle, WA 08-December-2017

Front-End Developer
Source: Indeed
Details: Expert Proficiency with HTML5, CSS and JavaScript. We are looking for a front-end developer (back-end development experience a plus) responsible for the...  More
10 days ago

Cincinnati, OH 45202 05-December-2017

Front-End Web Designer
Source: SLAM! Agency
Details: -- LOCAL CANDIDATES ONLY -- Do you geek out over HTML5 & CSS3? Are you truly passionate about user experience? Can you hold your own when it comes to graphic...  More
30+ days ago

St. Louis, MO 63110 08-October-2017

Web Developer & Designer
Source: Indeed
Details: Advanced HTML5, CSS3, and core Javascript. The ideal candidate will have 1-3 years of professional experience working with HTML5, CSS3, JavaScript, and jQuery....  More
30 days ago

Washington, DC 15-November-2017

Front-End Software Engineer (all levels) - Application Development
Source: Desk.com
Details: Solid understanding of web technologies, such as JavaScript, CSS, HTML5, XML, JavaScript, JSON, and/or Ajax....  More
30+ days ago

San Francisco, CA 09-November-2017

Web Developer
Source: Smith + Crown
Details: Highly fluent in standard front-end tools, frameworks, practices and technologies (Git, HTML5, Bulma, SCSS, Webpack, etc.)....  More
2 days ago

Portland, OR 13-December-2017

Web Developer
Source: VS Networks
Details: Ability to create responsive, cross-browser websites using HTML5, CSS3, and JavaScript. Ephrata, PA 17522....  More
24 days ago

Ephrata, PA 22-November-2017

Front End Developer
Source: RevContent
Details: JavaScript, HTML5, CSS, plus frameworks and libraries such as JQuery, AngularJS, Bootstrap. Revcontent is currently seeking a Front End Developer to join our...  More
1 day ago

Sarasota, FL 34243 14-December-2017

Front End Developer
Source: Martin Ventures
Details: Experience with front end technologies including HTML5, CSS3, SCSS, jQuery, AngularJS, Aurelia, ECMAScript 6/Typescript....  More
30+ days ago

Nashville, TN 37215 26-October-2017

Front-End Developer
Source: Genuine People
Details: Experienced in HTML5 (Canvas/WebGL/WebAudio API/Etc). Have strong understanding of web markup, including HTML5 and CSS3....  More
30+ days ago

San Francisco, CA 19-August-2017

Front End Developer
Source: IMGE
Details: Strong understanding of Wordpress, Javascript, HTML5, PHP, and CSS3. This opportunity is suited for a fast-paced, organized individual who can use their HTML5,...  More
16 days ago

Alexandria, VA 22314 29-November-2017

Front End Developer
Source: Centeva
Details: HTML5, CSS, SQL, AJAX, jQuery, and web services. Fast growing firm specializing in Federal Acquisition and Data Management seeks a front end developer to design...  More
29 days ago

Logan, UT 84321 17-November-2017

Front End Developer
Source: DealerOn, Inc.
Details: Knowledge of the latest trends in design and front-end website development (Bootstrap, HTML5, CSS3, responsive design, SASS etc.)....  More
30 days ago

Rockville, MD 20855 16-November-2017

Top 10 Interview Questions and Answers Series:

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