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

Senior Software UI Developer
Source: Indeed
Details: Angular, Node.js, HTML5, CSS3, AJAX and CORS:. JavaScript, jQuery, Angular 2, node.js, HTML5, CSS3, RESTFUL APIs, Twig, Smarty Versioning:....  More
1 day ago

Englewood Cliffs, NJ 07632 28-April-2017

Full Stack Developer
Source: Kaufman Rossin
Details: Experience with JavaScript, Ruby, HTML5, CSS3, Ember. Kaufman Rossin is seeking a Developer to join our Technology Development team....  More
20 days ago

Miami, FL 09-April-2017

Quality Assurance Analyst
Source: Indeed
Details: Experience in HTML5, CSS and it least one Object Oriented Programming language. Aptera is seeking a QA Engineer to join our tight-knit, progressive and growing...  More
24 days ago

Fort Wayne, IN 46802 05-April-2017

Marketing Web Developer, Fulfillment by Amazon
Source: Amazon.com
Details: Experience using modern web development technologies and techniques, including HTML5, CSS, JavaScript, Responsive Design, web services, etc....  More
4 days ago

Seattle, WA 26-April-2017

Front End Web Developer
Source: Fred Hutchinson Cancer Research Center
Details: Expert understanding of web technologies HTML5, CSS3. Cures Start Here....  More
8 days ago

Seattle, WA 98109 21-April-2017

Web Developer
Source: Diverse Lynx LLC
Details: Website building, website deployment/hosting, HTML5, JavaScript, and other skills necessary for FE and BE web development. Phone/Skype....  More
11 days ago

Redmond, WA 19-April-2017

Web Developer - Alexa
Source: Amazon.com
Details: Experience using modern web development technologies and techniques, including HTML5, CSS, JavaScript, Responsive Design, web services, etc....  More
11 days ago

Seattle, WA 18-April-2017

Web Developer
Source: Amazon.com
Details: Experience with modern web technologies and techniques such as HTML5, CSS3, javascript transpilers, and javascript build tools....  More
3 days ago

Seattle, WA 27-April-2017

PHP Web Developer
Source: ClientSolv Technologies
Details: The PHP Web Dveeloper should be able to apply past experience with CSS, HTML5, PHP, and Javascript to produce a cohesive application for presenting corporate...  More
26 days ago

Kirkland, WA 04-April-2017

Data Analytics/Web Developer
Source: Lockheed Martin
Details: This position is for a Data Analytics Engineer working for Lockheed Martin Enterprise Business Services (EBS). WORK LOCATION IS AT A MAJOR LOCKHEED MARTIN EBS  More
18 hours ago

King of Prussia, PA 19406 29-April-2017

Web Developer
Source: Colliers International
Details: About Colliers International Colliers International Group Inc. (NASDAQ and TSX: CIGI) is an industry-leading global real estate services company with 15,000  More
19 hours ago

Atlanta, GA 29-April-2017

Web Developer
Source: Campus Management
Details: CSS, HTML5, XML, ASP.NET. The ideal candidate will have development experience in web UIs using HTML5, CSS3, JavaScript, Bootstrap and AngularJS....  More
23 hours ago

Houston, TX 77036 29-April-2017

Front End Web Developer
Source: Synecore
Details: A strong understanding of HTML5, CSS, and PHP. Synecore is seeking a front end web developer to help design, build, and maintain websites for our clients....  More
22 hours ago

United States 29-April-2017

Front End Developer
Source: SchoolStatus
Details: Proficient understanding of web markup, including HTML5 and CSS3. SchoolStatus is looking for a Front-End Web/Mobile Developer who is motivated to combine the...  More
11 hours ago

Atlanta, GA 30305 29-April-2017

Front End Developer
Source: SchoolStatus
Details: Proficient understanding of web markup, including HTML5 and CSS3. SchoolStatus is looking for a Front-End Web/Mobile Developer who is motivated to combine the...  More
11 hours ago

Ridgeland, MS 29-April-2017

Web Developer UI/UX Superstar
Source: Indeed
Details: 3+ years of experience as a Front End Engineer, Web Developer, UI Developer or similar role- Mastery of modern development technologies and techniques,...  More
3 days ago

Kirkland, WA 98033 26-April-2017

Web App Developer
Source: Esri
Details: Experience with industry-standard technologies such as HTML, CSS, XML, XSLT, Git, HTML5, Dojo, and/or JavaScript and mobile application development experience....  More
17 days ago

Redlands, CA 13-April-2017

Front-End Web Developer
Source: Indeed
Details: 2+ years of expertise in HTML5, CSS3, JavaScript, ASP .NET MVC and C#. Allytics is looking for a talented and passionate Front-End Web Developer to join our...  More
1 day ago

Redmond, WA 98052 28-April-2017

Full Stack Web Developer
Source: Growth By Design
Details: Excellent HTML5 and CSS3 programming skills. Due to tremendous growth, we are looking to hire a talented Full Stack Web Developer with a solid knowledge in...  More
1 day ago

Duluth, GA 29-April-2017

Web Developer Internship
Source: ASRC Federal
Details: PHP, Python, Java, HTML, HTML5, C++, JavaScript, JQuery, ColdFusion. Web Developer Internship....  More
1 day ago

Greenbelt, MD 28-April-2017

Web Developer
Source: Engility Corporation
Details: Demonstrated experience using web development languages including HTML5, CSS, Javascript and PHP. Engility is seeking an experienced Web Developer to join the...  More
1 day ago

Chantilly, VA 20151 28-April-2017

Front End Web Developer
Source: Orvis
Details: Essential web markup, including HTML5, CSS3. Our Ecommerce Team is searching for a mid-to-senior level Front End Web Developer to join our IT group in...  More
1 day ago

Sunderland, VT 28-April-2017

Marketing Web Developer
Source: Conversant Media
Details: Marketing Web Developer - ( 0085288 ) The Front-end Developer for our Creative Marketing team is a unique opportunity for you to play an integral part in...  More
1 day ago

Chicago, IL 60606 28-April-2017

Web Developer / Digital Media Ad Processor
Source: Transworld
Details: Need fundamental understanding of HTML5 and coding it. Online HTML based advertising....  More
1 day ago

Dallas, TX 28-April-2017

Web Developer
Source: George Washington University
Details: Applies a knowledge of HTML5 and Mobile Friendly development, including CSS Frameworks. Knowledge of HTML5 and Mobile Friendly development, including CSS...  More
2 days ago

Ashburn, VA 20147 27-April-2017

Top 10 Interview Questions and Answers Series:

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