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

Sr. Tableau Developer/ Sr. Data Analyst/Architect
Source: Indeed
Details: Familiar with front end development with HTML5 and CSS3. Aricent is a global design and engineering company innovating for the digital era....  More
6 days ago

Sunnyvale, CA 19-June-2017

Front End Web Developer
Source: Ledgent Technology & Engineering
Details: My client has an urgent need for a Front End Web Developer with extensive experience with JavaScript, CSS, HTML, Gulp and Git We are an equal opportunity  More
4 days ago

Irvine, CA 21-June-2017

Front-End Web Developer (Cumberland, RI)
Source: ION AUDIO, LLC.
Details: Creates semantic HTML5 / CSS markup that maintains cross browser compatibility. InMusic Brands, Inc....  More
4 days ago

Cumberland, RI 02864 21-June-2017

Java Programmer
Source: Consultants 2 Go
Details: HTML5, CSS3, XML, JSON, jQuery, Ajax, Angular/React. C2G has an immediate full-time W2 contract position for a Java Web Developer to develop and support web...  More
4 days ago

Bedminster, NJ 22-June-2017

Front End Web Developer
Source: My Digital Shield
Details: Master-level HTML5, CSS3 and JavaScript coding capabilities. Work from home or our office....  More
9 days ago

Work at Home 17-June-2017

Back End Web Developer
Source: My Digital Shield
Details: HTML5, CSS3 and JavaScript coding capabilities. Work from home or our office....  More
9 days ago

Work at Home 17-June-2017

Front End Web Developer
Source: Onsharp
Details: HTML5 and CSS3. At Onsharp, we work in a fast-paced environment where input and innovations are always valued....  More
13 days ago

Fargo, ND 58103 13-June-2017

Front-End Web Developer
Source: Wyatt Investment Research
Details: Proficiency with HTML5, CSS3, Javascript, jQuery, PHP. Seeking a talented Front-End Web Developer with 2 – 5 years of experience....  More
17 days ago

Richmond, VT 09-June-2017

Front End Web Developer
Source: Summit Sports
Details: You will work with HTML5, CSS and Javascript as well as the proprietary Demandware toolset (DemandwareScript, pipelines, ISML templates) to customize Demandware...  More
17 days ago

Bloomfield Hills, MI 09-June-2017

Sr Front-End Web Developer
Source: Xpressdocs
Details: JQuery, Bootstrap, HTML5 certifications are a plus. 5+ years of Bootstrap, jQuery, HTML5 development experience....  More
21 days ago

Fort Worth, TX 76137 05-June-2017

Front-end Web Developer
Source: Bowen Media
Details: Solid knowledge of HTML5, CSS3 and CSS pre-processors (SASS). BOWEN is a top Long Island-based digital agency looking for a talented and experienced Front-end...  More
30+ days ago

Garden City Park, NY 10-May-2017

Principal Engineer
Source: Indeed
Details: C#, .NET, ASP.NET MVC, WCF, Rest, WebAPI, HTML5, AJAX, JSON, JQuery, ServiceBus, RabbitMQ, TeamCity and similar....  More
30+ days ago

Austin, TX 22-May-2017

Front End Web Developer
Source: Corefact
Details: Proficient understanding of web markup, including HTML5, CSS3. Do you like to work on an application stack that has a broad set of features, spanning different...  More
25 days ago

Hayward, CA 94545 31-May-2017

Front-End Web Developer
Source: HOTELS AT HOME
Details: Knowledge of HTML5 and CSS3. We are looking to add talented web developers who are excited to learn about new technologies and can adapt as needed....  More
26 days ago

Essex County, NJ 31-May-2017

Front-end Web Developer Internship
Source: CompAndSave.com
Details: A well-rounded web programming skill set such as HTML5, CSS3, JavaScript. Temporary/ Internship Position....  More
30+ days ago

Newark, CA 26-April-2017

Front-End Web Developer
Source: Stern Strategy Group
Details: HTML5, CSS, JavaScript/jQuery, WordPress, PHP, plus new frameworks and languages). Web design and development technologies including Adobe Creative Suite, HTML5...  More
30+ days ago

Iselin, NJ 26-May-2017

Entry Level Web Developer
Source: Indeed
Details: Knowledge and experience with HTML5 and CSS. Justice Works, LLC is a Centerville, UT based software services provider of legal case management solutions....  More
3 days ago

Centerville, UT 84014 22-June-2017

Front-End Web Developer - Contractor
Source: CHEP
Details: HTML5 and "One page" App design. CHEP is the world leader in pallet and container pooling services, serving many of the world's largest companies....  More
25 days ago

Orlando, FL 32819 01-June-2017

Web Developer
Source: Indeed
Details: BA/BS degree or equivalent working experience.Strong background with HTML5, CSS3, JavaScript, and jQuery.Domain expertise in UI/UX best practices....  More
4 days ago

Menlo Park, CA 21-June-2017

Support Web Developer (Remote)
Source: Indeed
Details: Advanced-level WordPress, PHP, JavaScript (ES6/ES2015 a plus), MySQL, HTML5, CSS3 knowledge. We're looking for a talented web developer/1099-contractor to help...  More
12 days ago

Goldsboro, NC 27530 13-June-2017

Front - End Web Developer
Source: InMoment
Details: Strong understanding of HTML5, CSS3 and PHP (compliant with web standards), responsive design techniques, a firm grasp of JavaScript....  More
30+ days ago

Murray, UT 11-May-2017

Front End Web Developer (Mid-Level)
Source: Brightidea
Details: Working knowledge of CSS3 (SASS/LESS preferred) and HTML5 with a strong attention to detail, polish, and responsive design....  More
30+ days ago

San Francisco, CA 09-May-2017

Jr. Front-End Web Developer
Source: HigherVisibility
Details: Proficient understanding of web markup, including HTML5, CSS3. HigherVisibility is looking for a Jr....  More
30+ days ago

Collierville, TN 09-May-2017

Jr. Front-End Web Developer
Source: HigherVisibility
Details: Proficient understanding of web markup, including HTML5, CSS3. HigherVisibility is looking for a Jr....  More
30+ days ago

Germantown, TN 09-May-2017

Jr. Front-End Web Developer
Source: HigherVisibility
Details: Proficient understanding of web markup, including HTML5, CSS3. HigherVisibility is looking for a Jr....  More
30+ days ago

Memphis, TN 09-May-2017

Top 10 Interview Questions and Answers Series:

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