0% found this document useful (0 votes)
14 views

PDF Responsive Web Design with AngularJS Sandeep Kumar Patel download

The document promotes the ebook 'Responsive Web Design with AngularJS' by Sandeep Kumar Patel, available for download on ebookmeta.com. It includes links to additional recommended ebooks on responsive web design and related topics. The book aims to teach readers how to build responsive single-page applications using AngularJS, covering various key features and approaches.

Uploaded by

eunjemulac
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

PDF Responsive Web Design with AngularJS Sandeep Kumar Patel download

The document promotes the ebook 'Responsive Web Design with AngularJS' by Sandeep Kumar Patel, available for download on ebookmeta.com. It includes links to additional recommended ebooks on responsive web design and related topics. The book aims to teach readers how to build responsive single-page applications using AngularJS, covering various key features and approaches.

Uploaded by

eunjemulac
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Responsive Web Design with AngularJS Sandeep Kumar


Patel

https://ebookmeta.com/product/responsive-web-design-with-
angularjs-sandeep-kumar-patel/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Responsive Web Design with HTML5 and CSS3 Second Edition


Ben Frain

https://ebookmeta.com/product/responsive-web-design-with-html5-and-
css3-second-edition-ben-frain/

ebookmeta.com

Responsive Web Design by Example Beginner s Guide 2nd


Edition Thoriq Firdaus

https://ebookmeta.com/product/responsive-web-design-by-example-
beginner-s-guide-2nd-edition-thoriq-firdaus/

ebookmeta.com

Responsible Responsive Design Scott Jehl

https://ebookmeta.com/product/responsible-responsive-design-scott-
jehl/

ebookmeta.com

Histone Modifications in Therapy 1st Edition Pedro Castelo


Branco Carmen Jeronimo

https://ebookmeta.com/product/histone-modifications-in-therapy-1st-
edition-pedro-castelo-branco-carmen-jeronimo/

ebookmeta.com
Remain Silent Erin McCabe Legal Thriller 3 1st Edition
Gigl

https://ebookmeta.com/product/remain-silent-erin-mccabe-legal-
thriller-3-1st-edition-gigl/

ebookmeta.com

Cryogenic Heat Management: Technology and Applications for


Science and Industry 1st Edition James E. Fesmire

https://ebookmeta.com/product/cryogenic-heat-management-technology-
and-applications-for-science-and-industry-1st-edition-james-e-fesmire/

ebookmeta.com

Thomas Cranmer 1st Edition Susan Wabuda

https://ebookmeta.com/product/thomas-cranmer-1st-edition-susan-wabuda/

ebookmeta.com

Checkers for the Freestyle Expert Richard Pask

https://ebookmeta.com/product/checkers-for-the-freestyle-expert-
richard-pask/

ebookmeta.com

Jurists and Legal Science in the History of Roman Law 1st


Edition Taylor & Francis Group

https://ebookmeta.com/product/jurists-and-legal-science-in-the-
history-of-roman-law-1st-edition-taylor-francis-group/

ebookmeta.com
City of Mist Master of Ceremonies Toolkit 1st Edition Amít
Moshe

https://ebookmeta.com/product/city-of-mist-master-of-ceremonies-
toolkit-1st-edition-amit-moshe/

ebookmeta.com
Responsive Web Design
with AngularJS

Leverage the core functionalities of AngularJS, to build


responsive single page applications

Sandeep Kumar Patel

BIRMINGHAM - MUMBAI
Responsive Web Design with AngularJS

Copyright © 2014 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book
is sold without warranty, either express or implied. Neither the author nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: December 2014

Production reference: 1131214

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78439-842-2
www.packtpub.com
Credits

Author Project Coordinator


Sandeep Kumar Patel Purav Motiwalla

Reviewers Proofreaders
Anthony Chu Simran Bhogal
Shaunak De Ameesha Green
Jude Osborn
Indexer
Commissioning Editor Rekha Nair
Julian Ursell
Graphics
Acquisition Editor Abhinash Sahu
Subho Gupta
Production Coordinator
Content Development Editor Melwyn D'sa
Arwa Manasawala
Cover Work
Technical Editor Melwyn D'sa
Utkarsha S. Kadam

Copy Editor
Merilyn Pereira
About the Author

Sandeep Kumar Patel is a senior web developer and founder of


www.tutorialsavvy.com, a widely read programming blog created in 2012. He
has more than 5 years of experience in object-oriented JavaScript and JSON-based
web applications development. He is GATE-2005 Information Technology (IT)
qualified and has a Master's degree from VIT University, Vellore. At present, he
works as a web developer at SAP Labs India. You can learn more about him from his
LinkedIn profile at http://www.linkedin.com/in/techblogger. He has received
the Dzone Most Valuable Blogger (MVB) award for technical publications related
to web technologies. His articles can be viewed at http://www.dzone.com/users/
sandeepgiet. He has also received the Java Code Geek (JCG) badge for a technical
article published in JCG. His article can be viewed at http://www.javacodegeeks.
com/author/sandeep-kumar-patel/.

He has also worked on: Instant GSON and Developing Responsive Web Applications with
AJAX and jQuery, both by Packt Publishing.

I would like to thank the three most important people in my life, my


parents, Dilip Kumar Patel and Sanjukta Patel, for their love and my
wife, Surabhi Patel, for her support and the joy that she has brought
to my life.
A special thanks to the team at Packt Publishing without whom this
book wouldn't have been possible.
About the Reviewers

Anthony Chu has been developing web applications for over 15 years. As a lead
developer and architect, he works with a team of talented developers building
AngularJS applications on Microsoft's ASP.NET and the Azure stack. Anthony lives
in Vancouver, Canada with his wife and two children. He blogs at anthonychu.com
and his Twitter handle is @nthonyChu.

Shaunak De has been working with imaging, Web-technologies, cluster and cloud
computing for over 8 years. He has keen interest in the developments of backends
and scientific computing for the Web. A valedictorian of the University of Mumbai,
he is currently pursuing his PhD at the Indian Institute of Technology in the domain
of Deep Learning.

Shaunak can be found on Twitter @shaunakde and on his journal at


http://shaunak.ws.

Jude Osborn is a creative developer for Google's Creative Lab in Sydney, on behalf
of development agency, Potato. Originally from the US, he has travelled a lot. Jude's
experience spans 20 years of software development, including the desktop, Web, and
mobile. He loves to learn and play with sweet new technologies, and is currently
thoroughly enjoying WebGL, AngularJS, and Chromecast.

Every day Jude walks across Sydney's Pyrmont Bridge, soaking up the sunshine
and looking forward to his next technological challenge.
www.PacktPub.com

Support files, eBooks, discount offers,


and more
For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface 1
Chapter 1: Introduction to Responsive Single Page Application
and AngularJS 7
Why responsive design? 7
What is single page web application? 8
Template 8
Partial 9
Router 9
Controller 9
Real-time communication 9
Local storage 9
Understanding responsive single page application 10
What is an AngularJS framework? 10
Exploring the features of AngularJS 10
The AngularJS module 11
The controller scope 11
The AngularJS routing module 12
The AngularJS provider 13
Data binding 14
AngularJS expressions 15
Built-in directive 15
Custom directive 16
Role of AngularJS 18
Using the browser sniffing approach 19
CSS3 media queries approach 20
Media type 21
Media feature 22
What are we building? 24
Summary 24
Table of Contents

Chapter 2: The AngularJS Dynamic Routing-based Approach 25


Setting up an AngularJS project 25
Building a project's structure 26
The SASS configuration 30
Profile application demo 31
Building data services 31
Device-based routing 32
AngularJS routing 33
Setting up an AngularJS application 33
Configuring a routing module 34
Configuring a profile controller 36
Developing a device type provider 37
Developing a desktop view 38
Name and profile image row 38
Category selection row 39
Category content 40
Social buttons row 41
Developing a mobile view 44
Developing a tablet view 47
Verifying responsiveness 51
Limitations of dynamic routing 54
Summary 54
Chapter 3: The AngularJS Directive-based Approach 55
Modifying the project structure 55
Changes in the directory structure 56
Changes in the routing module 56
Changes in the profile template 57
Directives 57
The $window service 58
The $watch method 59
The event binding function 60
The $log service 61
Built-in directives 62
Custom directives 62
Responsive directives 62
Responsive images 63
Responsive text 66
Responsive item lists 72
Summary 77

[ ii ]
Table of Contents

Chapter 4: The AngularJS-based Breakpoints


for Layout Manipulation 79
Page layout 79
Layout type 80
Breakpoints 80
Responsive and common breakpoints 80
AngularJS publisher and subscriber 81
Publishing a message using $emit 81
Publishing a message using $broadcast 81
Subscribing to a message using $on 82
The difference between $emit and $broadcast 84
An example of the publish and subscribe mechanism 85
Custom attributes 87
Developing a custom attribute 88
Implementing a custom attribute 90
Summary 95
Chapter 5: Debugging and Testing Responsive Applications 97
Batarang 97
Installing and configuring Batarang 97
Using Batarang 98
AngularJS scope inspector 0.1.2 100
Online and offline tools 101
Online tools 101
The responsive design checker tool 102
The responsive test online tool 102
Offline tools 103
Chrome developer emulation 103
Opera mobile emulator 104
FireBreak add-ons 106
Summary 107
Index 109

[ iii ]
Preface
Welcome to Responsive Web Design with AngularJS. If you want to learn and understand
responsive web application development using AngularJS, then this book is for you.
It covers a systematic approach to build a responsive web application.

All the key features of AngularJS that can help in building a responsive application
are explained with the detailed code. This book also explains how to debug and test
an AngularJS-based web application during development.

What this book covers


Chapter 1, Introduction to Responsive Single Page Application and AngularJS, introduces
you to responsive design, single page application, and the AngularJS library. This
chapter also gives a kick start of the single page responsive application that we are
going to build to demonstrate the AngularJS role in application development.

Chapter 2, The AngularJS Dynamic Routing-based Approach, explores the power of


AngularJS-based routing of templates. It also explores the use of AngularJS routing
for responsive web application development.

Chapter 3, The AngularJS Directive-based Approach, introduces the custom directive


development in Angular JS. It also demonstrates the building of custom directives
to address responsive web application development.

Chapter 4, The AngularJS-based Breakpoints for Layout Manipulation, introduces


the CSS3 breakpoint concept for responsive layout development. It also provides
coded examples in AngularJS to present the breakpoint concept in the context of
web design.

Chapter 5, Debugging and Testing Responsive Applications, provides a list of debugging


tools for AngularJS-based applications.
Preface

What you need for this book


The tools and libraries required for this book are as follows:

• WebStorm or Sublime Text


• The WAMP server or WebStorm default server
• AngularJS 1.3
• SASS
• COMPASS
• Ruby 64-bit

Who this book is for


If you are an AngularJS developer who wants to create responsive web
applications, this is the book for you. It is also helpful for those who want to
learn different approaches provided by AngularJS to develop a responsive
single page web application. Finally, the book is for anyone who wants to
understand AngularJS-based responsive web application development.

Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"The $window object has many useful properties that can be used for application
development."

A block of code is set as follows:


<div class="row">
<div class="pic">
<h1 class="name">Sandeep Kumar Patel</h1>
<img class="profile-image"
src="http://www.gravatar.com/avatar/4205261332ff1
31e971b48db31dcb528.png"
alt="profile image"/>
</div>
</div>

[2]
Preface

When we wish to draw your attention to a particular part of a code block,


the relevant lines or items are set in bold:
angular.module('profileApp.profileServices', [])
.service('ProfileServices',["$resource", function($resource){
return{
/*Method for getting personal detail JSON file*/
getPersonalDetail : function(){
return $resource("data/personalDetail.json")
},
/*Method for getting professional detail JSON file*/
getProfessionalDetail : function(){
return $resource("data/professionalDetail.json")
}`
}
}]);

Any command-line input or output is written as follows:


require 'compass/import-once/activate'
#root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "sass"

New terms and important words are shown in bold. Words that you see on the screen,
for example, in menus or dialog boxes, appear in the text like this: "To use Batarang
you need to select the Enabled checkbox to debug the AngularJS application."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it helps
us develop titles that you will really get the most out of.

[3]
Preface

To send us general feedback, simply e-mail [email protected], and mention


the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt Publishing book, we have a number
of things to help you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. If you
purchased this book elsewhere, you can visit http://www.packtpub.com/support
and register to have the files e-mailed directly to you.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt Publishing, we take the protection of our copyright and licenses very
seriously. If you come across any illegal copies of our works in any form on the
Internet, please provide us with the location address or website name immediately
so that we can pursue a remedy.

[4]
Another Random Document on
Scribd Without Any Related Topics
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like