Mastering Web Application Development with AngularJS


Mastering Web Application Development with AngularJS
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Make the most out of AngularJS by understanding the AngularJS philosophy and applying it to real life development tasks
  • Effectively structure, write, test, and finally deploy your application
  • Add security and optimization features to your AngularJS applications
  • Harness the full power of AngularJS by creating your own directives
  • Full of solutions to real life problems, with clear explanations of the more sophisticated AngularJS concepts

Book Details

Language : English
Paperback : 372 pages [ 235mm x 191mm ]
Release Date : August 2013
ISBN : 1782161821
ISBN 13 : 9781782161820
Author(s) : Peter Bacon Darwin, Pawel Kozlowski
Topics and Technologies : All Books, Web Development, Open Source

Table of Contents

Preface
Chapter 1: Angular Zen
Chapter 2: Building and Testing
Chapter 3: Communicating with a Back-end Server
Chapter 4: Displaying and Formatting Data
Chapter 5: Creating Advanced Forms
Chapter 6: Organizing Navigation
Chapter 7: Securing Your Application
Chapter 8: Building Your Own Directives
Chapter 9: Building Advanced Directives
Chapter 10: Building AngularJS Web Applications for an International Audience
Chapter 11: Writing Robust AngularJS Web Applications
Chapter 12: Packaging and Deploying AngularJS Web Applications
Index
  • Chapter 1: Angular Zen
    • Meet AngularJS
      • Getting familiar with the framework
      • Finding your way in the project
        • The community
        • Online learning resources
      • Libraries and extensions
      • Tools
        • Batarang
        • Plunker and jsFiddle
        • IDE extensions and plugins
    • AngularJS crash course
      • Hello World – the AngularJS example
        • Two-way data binding
      • The MVC pattern in AngularJS
        • Bird's eye view
        • Scopes in depth
        • View
      • Modules and dependency injection
        • Modules in AngularJS
        • Collaborating objects
        • Registering services
        • Modules lifecycle
        • Modules depending on other modules
    • AngularJS and the rest of the world
      • jQuery and AngularJS
        • Apples and oranges
      • A sneak peek into the future
    • Summary
    • Chapter 2: Building and Testing
      • Introducing the sample application
        • Getting familiar with the problem domain
        • Technical stack
        • Persistence store
          • MongoLab
          • Server-side environment
          • Third-party JavaScript libraries
          • Bootstrap CSS
      • Build system
        • Build system principles
          • Automate everything
          • Fail fast, fail clean
          • Different workflows, different commands
          • Build scripts are code too
        • Tools
          • Grunt.js
          • Testing libraries and tools
          • Jasmine
          • Karma runner
      • Organizing files and folders
        • Root folders
        • Inside the source folder
          • AngularJS specific files
          • Start simple
          • Inside the test folder
        • File-naming conventions
      • AngularJS modules and files
        • One file, one module
        • Inside a module
          • Different syntax for registering providers
          • Syntax for declaring the configure and run blocks
      • Automated testing
        • Unit tests
          • Anatomy of a Jasmine test
          • Testing AngularJS objects
          • Testing services
          • Testing controllers
          • Mock objects and asynchronous code testing
        • End-to-end tests
          • Daily workflow
          • Karma runner tips and tricks
          • Executing a subset of tests
          • Debugging
      • Summary
      • Chapter 3: Communicating with a Back-end Server
        • Making XHR and JSONP requests with $http
          • Getting familiar with the data model and MongoLab URLs
          • $http APIs quick tour
            • The configuration object primer
            • Request data conversion
            • Dealing with HTTP responses
            • Response data conversion
          • Dealing with same-origin policy restrictions
            • Overcoming same-origin policy restrictions with JSONP
            • JSONP limitations
            • Overcoming same-origin policy restrictions with CORS
            • Server-side proxies
        • The promise API with $q
          • Working with promises and the $q service
            • Learning $q service basics
            • Promises are first-class JavaScript objects
            • Aggregating callbacks
            • Registering callbacks and the promise lifecycle
            • Asynchronous action chaining
            • More on $q
          • $q integration in AngularJS
        • The promise API with $http
        • Communicating with RESTful endpoints
          • The $resource service
            • Constructor-level and instance-level methods
            • $resource creates asynchronous methods
            • Limitations of the $resource service
          • Custom REST adapters with $http
        • Using advanced features of $http
          • Intercepting responses
        • Testing code that interacts with $http
        • Summary
        • Chapter 4: Displaying and Formatting Data
          • Referencing directives
          • Displaying results of expression evaluation
            • The interpolation directive
            • Rendering model values with ngBind
            • HTML content in AngularJS expressions
          • Conditional display
            • Including blocks of content conditionally
          • Rendering collections with the ngRepeat directive
            • Getting familiar with the ngRepeat directive
            • Special variables
            • Iterating over an object's properties
            • ngRepeat patterns
              • Lists and details
              • Altering tables, rows, and classes
          • DOM event handlers
          • Working effectively with DOM-based templates
            • Living with verbose syntax
            • ngRepeat and multiple DOM elements
            • Elements and attributes that can't be modified at runtime
            • Custom HTML elements and older versions of IE
          • Handling model transformations with filters
            • Working with built-in filters
              • Formatting filters
              • Array-transforming filters
            • Writing custom filters – a pagination example
            • Accessing filters from the JavaScript code
            • Filters dos and don'ts
              • Filters and DOM manipulation
              • Costly data transformations in filters
              • Unstable filters
          • Summary
          • Chapter 5: Creating Advanced Forms
            • Comparing traditional forms with AngularJS forms
              • Introducing the ngModel directive
            • Creating a User Information Form
            • Understanding the input directives
              • Adding the required validation
              • Using text-based inputs (text, textarea, e-mail, URL, number)
              • Using checkbox inputs
              • Using radio inputs
              • Using select inputs
                • Providing simple string options
                • Providing dynamic options with the ngOptions directive
                • Using empty options with the select directive
                • Understanding select and object equivalence
                • Selecting multiple options
              • Working with traditional HTML hidden input fields
                • Embedding values from the server
                • Submitting a traditional HTML form
            • Looking inside ngModel data binding
              • Understanding ngModelController
                • Transforming the value between the model and the view
                • Tracking whether the value has changed
                • Tracking input field validity
            • Validating AngularJS forms
              • Understanding ngFormController
                • Using the name attribute to attach forms to the scope
              • Adding dynamic behavior to the User Information Form
                • Showing validation errors
                • Disabling the save button
              • Disabling native browser validation
            • Nesting forms in other forms
              • Using subforms as reusable components
            • Repeating subforms
              • Validating repeated inputs
            • Handling traditional HTML form submission
              • Submitting forms directly to the server
              • Handling form submission events
                • Using ngSubmit to handle form submission
                • Using ngClick to handle form submission
            • Resetting the User Info form
            • Summary
            • Chapter 6: Organizing Navigation
              • URLs in single-page web applications
                • Hashbang URLs in the pre-HTML5 era
                • HTML5 and the history API
              • Using the $location service
                • Understanding the $location service API and URLs
                • Hashes, navigation within a page, and $anchorScroll
                • Configuring the HTML5 mode for URLs
                  • Client side
                  • Server side
                • Handcrafting navigation using the $location service
                  • Structuring pages around routes
                  • Mapping routes to URLs
                  • Defining controllers in route partials
                  • The missing bits in the handcrafted navigation
              • Using built-in AngularJS routing services
                • Basic routes definition
                  • Displaying the matched route's content
                • Matching flexible routes
                  • Defining default routes
                  • Accessing route parameter values
                • Reusing partials with different controllers
                • Avoiding UI flickering on route changes
                • Preventing route changes
              • Limitations of the $route service
                • One route corresponds to one rectangle on the screen
                  • Handling multiple UI rectangles with ng-include
                • No nested routes support
              • Routing-specific patterns, tips, and tricks
                • Handling links
                  • Creating clickable links
                  • Working with HTML5 and hashbang mode links consistently
                  • Linking to external pages
                • Organizing route definitions
                  • Spreading route definitions among several modules
                  • Fighting code duplication in route definitions
              • Summary
              • Chapter 7: Securing Your Application
                • Providing server-side authentication and authorization
                  • Handling unauthorized access
                  • Providing a server-side authentication API
                • Securing partial templates
                • Stopping malicious attacks
                  • Preventing cookie snooping (man-in-the-middle attacks)
                  • Preventing cross-site scripting attacks
                    • Securing HTML content in AngularJS expressions
                    • Allowing unsafe HTML bindings
                    • Sanitizing HTML
                  • Preventing the JSON injection vulnerability
                  • Preventing cross-site request forgery
                • Adding client-side security support
                  • Creating a security service
                  • Showing a login form
                  • Creating security-aware menus and toolbars
                    • Hiding the menu items
                    • Creating a login toolbar
                • Supporting authentication and authorization on the client
                  • Handling authorization failures
                  • Intercepting responses
                    • HTTP response interceptors
                  • Creating a securityInterceptor service
                  • Creating the securityRetryQueue service
                    • Notifying the security service
                • Preventing navigation to secure routes
                  • Using route resolve functions
                  • Creating the authorization service
                • Summary
                • Chapter 8: Building Your Own Directives
                  • What are AngularJS directives?
                    • Understanding the built-in directives
                    • Using directives in the HTML markup
                  • Following the directive compilation life-cycle
                  • Writing unit tests for directives
                  • Defining a directive
                  • Styling buttons with directives
                    • Writing a button directive
                  • Understanding AngularJS widget directives
                    • Writing a pagination directive
                    • Writing tests for the pagination directive
                    • Using an HTML template in a directive
                    • Isolating our directive from its parent scope
                      • Interpolating the attribute with @
                      • Binding data to the attribute with =
                      • Providing a callback expression in the attribute with &
                    • Implementing the widget
                    • Adding a selectPage callback to the directive
                  • Creating a custom validation directive
                    • Requiring a directive controller
                      • Making the controller optional
                      • Searching for parents for the controller
                    • Working with ngModelController
                    • Writing custom validation directive tests
                    • Implementing a custom validation directive
                  • Creating an asynchronous model validator
                    • Mocking up the Users service
                    • Writing tests for asynchronous validation
                    • Implementing the asynchronous validation directive
                  • Wrapping the jQueryUI datepicker directive
                    • Writing tests for directives that wrap libraries
                    • Implementing the jQuery datepicker directive
                  • Summary
                  • Chapter 9: Building Advanced Directives
                    • Using transclusion
                      • Using transclusion in directives
                      • Transcluding into an isolated scope directive
                      • Creating an alert directive that uses transclusion
                        • Understanding the replace property in the directive definition
                        • Understanding the transclude property in the directive definition
                        • Inserting the transcluded elements with ng-transclude
                      • Understanding the scope of transclusion
                    • Creating and working with transclusion functions
                      • Creating a transclusion function with the $compile service
                        • Cloning the original elements when transcluding
                      • Accessing transclusion functions in directives
                        • Getting the transclusion function in the compile function with transcludeFn
                        • Getting the transclusion function in the directive controller with $transclude
                      • Creating an if directive that uses transclusion
                        • Using the priority property in a directive
                    • Understanding directive controllers
                      • Injecting special dependencies into directive controllers
                      • Creating a controller-based pagination directive
                      • Understanding the difference between directive controllers and link functions
                        • Injecting dependencies
                        • The compilation process
                        • Accessing other controllers
                        • Accessing the transclusion function
                      • Creating an accordion directive suite
                        • Using a directive controller in accordion
                        • Implementing the accordion directive
                        • Implementing the accordion-group directive
                    • Taking control of the compilation process
                      • Creating a field directive
                        • Using the terminal property in directives
                      • Using the $interpolate service
                        • Binding to validation messages
                      • Loading templates dynamically
                      • Setting up the field template
                    • Summary
                    • Chapter 10: Building AngularJS Web Applications for an International Audience
                      • Using locale-specific symbols and settings
                        • Configuring locale-specific modules
                        • Making use of available locale settings
                          • Locale-specific settings and AngularJS filters
                      • Handling translations
                        • Handling translated strings used in AngularJS templates
                          • Using filters
                          • Using directives
                        • Handling translated strings used in the JavaScript code
                      • Patterns, tips, and tricks
                        • Initializing applications for a given locale
                          • Consequences of including locales as part of URLs
                        • Switching locales
                        • Custom formatting for dates, numbers, and currencies
                      • Summary
                      • Chapter 11: Writing Robust AngularJS Web Applications
                        • Understanding the inner workings of AngularJS
                          • It is not a string-based template engine
                            • Updating models in response to DOM events
                            • Propagating model changes to the DOM
                            • Synchronizing DOM and model
                            • Scope.$apply – a key to the AngularJS world
                            • Putting it all together
                        • Performance tuning – set expectations, measure, tune, and repeat
                        • Performance tuning of AngularJS applications
                          • Optimizing CPU utilization
                            • Speeding up $digest loops
                            • Entering the $digest loop less frequently
                            • Limit the number of turns per $digest loop
                          • Optimizing memory consumption
                            • Avoid deep-watching whenever possible
                            • Consider the size of expressions being watched
                          • The ng-repeat directive
                            • Collection watching in ng-repeat
                            • Many bindings made easy
                        • Summary
                        • Chapter 12: Packaging and Deploying AngularJS Web Applications
                          • Improving network-related performance
                            • Minifying static resources
                              • How does AngularJS infer dependencies?
                              • Writing minification-safe JavaScript code
                              • The pitfalls of array-style DI annotations
                            • Preloading templates
                              • Using the <script> directive to preload templates
                              • Filling in the $templateCache service
                              • Combining different preloading techniques
                          • Optimizing the landing page
                            • Avoid displaying templates in their unprocessed form
                              • Hiding portions of the DOM with ng-cloak
                              • Hiding individual expressions with ng-bind
                            • Including AngularJS and application scripts
                              • Referencing scripts
                              • AngularJS and Asynchronous Module Definition
                          • Supported browsers
                            • Working with Internet Explorer
                          • Summary

                          Peter Bacon Darwin

                          Peter Bacon Darwin has been programming for over two decades. He worked with .NET from before it was released; he contributed to the development of IronRuby and was an IT consultant for Avanade and IMGROUP before quitting to share his time between freelance development and looking after his kids. Peter is a notable figure in the AngularJS community. He has recently joined the AngularJS team at Google as an external contractor and is a founder member of the AngularUI project. He has spoken about AngularJS at Devoxx UK and numerous London meetups. He also runs training courses in AngularJS. His consultancy practice is now primarily focused on helping businesses make best use of AngularJS.

                          Pawel Kozlowski

                          Pawel Kozlowski has over 15 years of professional experience in web development and was fortunate enough to work with variety of web technologies, languages, and platforms. He is not afraid of hacking both at client side and server side and always searches for the most productive tools and processes. Pawel strongly believes in free, open source software. He has been very committed in the AngularJS project and also is very active in the AngularJS community. He also contributes to Angular UI – the companion suite to the AngularJS framework, where he focuses on the Twitter's Bootstrap directives for AngularJS. When not coding, Pawel spreads a good word about AngularJS at various conferences and meetups.
                          Sorry, we don't have any reviews for this title yet.

                          Code Downloads

                          Download the code and support files for this book.


                          Submit Errata

                          Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                          Errata

                          - 4 submitted: last submission 05 Sep 2013

                          Errata type: Code | Chapter number: 1, Page number: 15 | Errata date: 12-6-2013

                           

                          Chapter 1, page 15, paragraph 3:
                          
                          "The syntax of the ng-repeat directive
                          should be easy to follow - a new variable country is created for each item and exposed
                          on a $scope to by rendered by a view."
                          
                          Should be "...and exposed on a $scope to be rendered by a view."
                          
                          
                          Chapter 1, page 15, paragraph 1:
                          
                          "There can be many scope-creating directives in the DOM tree
                          and as a result many scopes will be crated."
                          
                          Should be "created"
                          
                          

                           

                           

                          Errata type: Code | Page number: 233

                          The reference on the fifth line ng-model="model.value" should be ng-model="model.testValue"
                          The reference on the fourteenth line $scope.value should be $scope.model.testValue

                          Errata type: Code | Page number: 69

                          The third line $log.info("Hello, " + name + "!"); should be $log.info("Hello, " + name + "!"); }, timeout )

                          Errata type: Code | Page number: 31

                          In the Factories section, the last paragraph
                          notificationToArchive service should be notificationsArchive service

                          Sample chapters

                          You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                          Frequently bought together

                          Mastering Web Application Development with AngularJS +    Openswan: Building and Integrating Virtual Private Networks =
                          50% Off
                          the eBooks
                          Price for both: ₨283.61

                          Buy both these recommended eBooks together and get 50% off the total price

                          What you will learn from this book

                          • Use AngularJS DOM-based templating effectively and learn how it differs from other frameworks
                          • Query and modify data in various backends and become proficient with the promise API
                          • Quickly create complex forms, taking full advantage of the 2-way data binding
                          • Introduce navigation in your web application by relaying on the HTML5 History API
                          • Manage dependencies with the AngularJS module and the Dependency Injection systems
                          • Localize your web application to prepare it for an international audience
                          • Secure your web application from unauthorized users
                          • Build a variety of AngularJS directives: widgets, validators, and wrapping 3rd party plugins
                          • Gain a deep understanding of the AngularJS compiler to build even more sophisticated directives
                          • Unit test AngularJS-specific JavaScript code using the Jasmine BDD testing framework
                          • Structure your web application by organizing it into a meaningful and flexible directory structure

                          In Detail

                          AngularJS is an open-source JavaScript framework. Its goal is to develop MVC-based web applications and reduce the amount of JavaScript needed to make web applications functional.

                          The book will take the reader through the workflow of building an AngularJS app.

                          Throughout the process of app creation, we will have a look at the different interaction points between design and development and the readers will learn how AngularJS helps both roles to build an application that works well, as well as how to create clean and maintainable front end markup and code.

                          Approach

                          This book will be a step-by-step guide showing the readers how to build a complete web app with AngularJS.

                          Who this book is for

                          This book will be most useful to developers who are evaluating or have decided to use AngularJS for a real life project. You should have some prior exposure to AngularJS, at least through basic examples. We assume that you’ve got working knowledge of HTML, CSS, and JavaScript.

                          Code Download and Errata
                          Packt Anytime, Anywhere
                          Register Books
                          Print Upgrades
                          eBook Downloads
                          Video Support
                          Contact Us
                          Awards Voting Nominations Previous Winners
                          Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                          Resources
                          Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software