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

UI/UX/Front-end Developer
Source: Indeed
Details: Development experience in or willing to learn front end technologies such as HTML5, Javascript, CSS3, SASS, Angular JS, Google Polymer, Backbone, SCSS, LESS etc...  More
12 days ago

Seattle, WA 98104 08-August-2017

UI/PHP Developer
Source: Indeed
Details: Javascript, css, jquery, Angular, HTML5, PHP*. Greetings from 8kmiles....  More
2 days ago

New York, NY 18-August-2017

UI Developer
Source: Indeed
Details: JavaScript, HTML5, CSS, Angular 2, Bootstrap, Java/J2EE Framework, Ajax, JSON, and restful web services. UI Developer Location;...  More
2 days ago

Atlanta, GA 18-August-2017

UI Developer W/ Redux
Source: Indeed
Details: UI design, development, and maintaining/updating existing projects Delivering high quality, responsive, HTML5, CSS3 and JavaScript components.*....  More
2 days ago

Phoenix, AZ 18-August-2017

UI/UX Developer
Source: Indeed
Details: Proficient understanding of web markup, including HTML5, CSS3, Flexbox. SoftSages Technology !!...  More
2 days ago

Boca Raton, FL 18-August-2017

UI Developer
Source: Indeed
Details: JavaScript, HTML5, CSS, Angular 2, Bootstrap, Java/J2EE Framework, Ajax, JSON, and restful web servicesA working knowledge of design patterns and service...  More
2 days ago

Atlanta, GA 18-August-2017

Sr. UI Developer
Source: Indeed
Details: Microsoft Azure, C#, .net framework core (4.6.1 and higher), MVC 5, Web API, REST ,Entity Framework, SignalR, SQL server 2016, Kendo UI API, HTML5, CSS,....  More
3 days ago

Houston, TX 17-August-2017

Looking for UI Developer at Ann Arbor, MI (Must be local)
Source: Indeed
Details: *Location- Ann Arbor, MI* *Title – UI Developer* *Interview- Must go onsite after phone interview (the client will NOT provide cost for f2f interview)* *No...  More
4 days ago

Mount Pleasant, MI 48859 16-August-2017

Front End UI Developer
Source: Indeed
Details: Experience with HTML5, CSS3, JQuery/Bootstrap, and JSONE. We are a start-up currently developing an ERP software application that will require us to create...  More
5 days ago

Remote 15-August-2017

UI Developer
Source: Indeed
Details: Html5, CSS and Javascript:. HTML 5, Java Script, CSS 3, JSON, Ajax, XAML, jQuery, Bootstrap, Angular, React and other modern frameworks....  More
5 days ago

Detroit, MI 15-August-2017

Sr. UI Developer - Englewood, NJ 45/Hr
Source: Indeed
Details: JavaScript, Angular 2, Node.js, Express, HTML5, CSS3, Git Personal Skills:. Hi,....  More
6 days ago

Englewood, NJ 15-August-2017

UI Developer
Source: Indeed
Details: JavaScript, Angular 2, Node.js, Express, HTML5, CSS3, and Git. Experience with client side technologies including Angular, Node.js, HTML5, and CSS3 and advanced...  More
6 days ago

San Diego, CA 14-August-2017

UI/UX Developer
Source: Indeed
Details: JavaScript, HTML5, CSS3, REST API, MySQL, Selenium, Websphere Commerce, Karma, Mocha. Hi,*....  More
6 days ago

Melville, NY 14-August-2017

Sr. UX/UI Developer
Source: Indeed
Details: Strong front-end development skills using HTML5, JavaScript, jQuery and Knockout (or other MVVM Foundation)....  More
11 days ago

Costa Mesa, CA 10-August-2017

UI Developer
Source: Indeed
Details: Expert level familiarity with HTML5, JavaScript, CSS3, SVG. About 5 years experience developing user interfaces for an enterprise application....  More
11 days ago

Fremont, CA 94538 09-August-2017

UI/UX developer
Source: Indeed
Details: Proficiency in HTML5, CSS3, JavaScript. Job Description – UI/UX Developer*....  More
11 days ago

San Luis Obispo, CA 09-August-2017

UI Developer
Source: Indeed
Details: Developing UIs in jQuery, CSS, HTML5, Handlebar, JavaScript, and Web services:. 3 to 5 years of experience with developing UIs in jQuery, CSS, HTML5, Handlebar,...  More
18 days ago

Alexandria, VA 02-August-2017

Front End / UI Developer
Source: Indeed
Details: Proficient with HTML, HTML5, CSS, CSS3, JSON, AJAX. Front End / UI Developer....  More
18 days ago

New York, NY 02-August-2017

Sr. UI/UX Developer
Source: Indeed
Details: Working proficiency of the HTML5 data attributes. UX/UI Lead Developer with emphasis on Mobile Development*....  More
19 days ago

Tampa, FL 01-August-2017

SR. UI Developer
Source: Indeed
Details: This role requires hands-on software development skills, deep technical expertise in web development, especially in developing HTML5, CSS3 and Object oriented...  More
24 days ago

Englewood, NJ 28-July-2017

UI and API Developer _Cloud storage expert
Source: Indeed
Details: Must have the working experience with Javascript, Angular 2, Typescript, HTML5 and CSS3. UI and API Developer*....  More
27 days ago

Houston, TX 24-July-2017

Frontend/UI Developer
Source: Indeed
Details: Experience with web languages/technologies including HTML5, CSS3, Responsive Web Design, Angular, jQuery, Ajax, JSON, etc....  More
30+ days ago

Minneapolis, MN 07-July-2017

Report Developer (Sql,Oracle,Crystal Reports)
Source: Indeed
Details: *Minimum 60 Months* Experience with SQL, PL/SQL, XML, stored procedures, functions, packages, and triggers and views. *Minimum 60 Months* Experience writing...  More
5 days ago

Albany, NY 15-August-2017

UI Developer
Source: Indeed
Details: HTML5 including HTML5 API’s. Knowledge of expanded HTML5 semantics and popular HTML5 APIs (e.g. 2+ years of experience with HTML5 and CSS3 and popular page...  More
30+ days ago

Edison, NJ 08820 29-June-2017

Full-time Adobe ColdFusion Developer with Front-end (UX/UI) Experience
Source: Indeed
Details: Minimum of 3 years of experience with HTML5, CSS3 and JavaScript/jQuery. USC Gould School of Law is looking for an experienced Adobe ColdFusion developer with...  More
30+ days ago

Los Angeles, CA 90089 27-June-2017

Top 10 Interview Questions and Answers Series:

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