You are previewing Learning AngularJS for .NET Developers.
O'Reilly logo
Learning AngularJS for .NET Developers

Book Description

Build single-page web applications using frameworks that help you work efficiently and deliver great results

In Detail

AngularJS is the most popular JavaScript MVC framework, and it embraces and extends HTML rather than abstracting it. The building of single-page applications is a web-designer-friendly process with the AngularJS expressive HTML vocabulary. It drastically reduces the amount of JavaScript required to control complex user interactions and enforces a modular approach to structuring your JavaScript code.

This book covers all of the stages of building a single-page web application, starting with frontend components powered by AngularJS, continuing with web services that leverage ServiceStack, and putting it all together in an ASP.NET MVC application. You will learn a development process focused on rapid delivery and testability for all application layers.

What You Will Learn

  • Create a standalone AngularJS application to prototype user interfaces
  • Validate complex forms with AngularJS and use Bootstrap to style them
  • Build RESTful web services that work well with single-page applications
  • Implement automatic validation for web service requests to reduce your boilerplate code
  • Use web services with AngularJS to offload and secure your application logic
  • Test your AngularJS and web service code to improve the quality of your software deliverables
  • Structure your JavaScript code and organize your files so your application can grow at a sustainable pace
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

    Table of Contents

    1. Learning AngularJS for .NET Developers
      1. Table of Contents
      2. Learning AngularJS for .NET Developers
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Introducing AngularJS
        1. Presenting AngularJS with examples
          1. A jQuery example
          2. An AngularJS example
          3. Introducing the AngularJS controller
          4. An overview of the AngularJS architecture
          5. The Model-View-Controller pattern
          6. The structure of an AngularJS application
            1. Bootstrapping an AngularJS application
            2. Defining module dependencies
        2. The JavaScript patterns and practices used in AngularJS applications
          1. Immediately-invoked Function Expression
          2. The revealing module pattern
          3. The strict mode of JavaScript
        3. Dependency injection
        4. Introducing AngularJS services
        5. Directives
          1. The ngRepeat directive
          2. The ngInclude directive
          3. Creating a custom directive
        6. Filters
        7. Summary
      9. 2. Creating an AngularJS Client-side Application in Visual Studio
        1. Using Visual Studio with NuGet to manage AngularJS and related libraries
          1. Introducing NuGet
          2. Using Visual Studio extensions for AngularJS
        2. Prototyping client-side components
        3. Organizing client-side code
        4. Integrating AngularJS with JavaScript libraries
          1. Native JavaScript libraries and AngularJS
          2. Third-party user interface libraries and AngularJS
        5. Routing
        6. Creating a bicycle rental management application
          1. Creating the application layout
          2. Implementing the Bicycles views
            1. The Bicycles index view
            2. The Bicycles new view
              1. Bootstrap form styles
              2. AngularJS form validation
            3. The Bicycles edit view
          3. Implementing the Customers views
          4. Implementing the Rentals views
        7. Summary
      10. 3. Creating .NET Web Services for AngularJS
        1. RESTful web services
        2. Choosing a RESTful web services framework
        3. Why ServiceStack is a great fit for AngularJS
        4. ServiceStack overview
          1. Setting up the ServiceStack starter project
          2. Creating ServiceStack web services
          3. Using the ServiceStack C# client
          4. The ServiceStack infrastructure
            1. Routing
            2. Request and response filters
            3. Dependency injection
            4. Automatic validation
        5. Creating web service methods for the sample application
          1. ServiceStack project structure
          2. Implementing Bicycles-related web services
            1. The GET web service methods
            2. The POST web service method
            3. The PUT web service method
            4. Merging PUT and POST request DTOs
        6. Calling RESTful web services in AngularJS using the ngResource module
          1. Using the $resource service
          2. Resource class methods
          3. Resource instance methods
          4. Custom resource methods
        7. Summary
      11. 4. Creating an AngularJS, ASP.NET MVC, ServiceStack Application
        1. Using ASP.NET MVC as the application backbone
          1. Why you should use ASP.NET MVC
          2. Adding ASP.NET MVC to the main sample application
          3. Integrating ASP.NET MVC with ServiceStack
          4. Routing considerations for ASP.NET MVC and AngularJS
          5. Using ASP.NET bundling and minification features for AngularJS files
        2. Securing the AngularJS application
          1. Using the ServiceStack.Mvc library
          2. The building blocks of the ServiceStack security infrastructure
          3. Introducing the AuthFeature plugin
          4. Implementing authentication for web services
          5. Implementing authentication for ASP.NET MVC controllers
        3. Pushing initial data from the server-side application to the AngularJS application
        4. How to ensure that AngularJS works well with the backend
          1. Handling the waiting time for long operations
          2. Handling exceptions and implementing generic animations
            1. Adding a $http interceptor
            2. Implementing spinner animations for all web service calls
        5. Adding database persistence
          1. Adding database persistence to the AuthFeature plugin
          2. Adding database persistence for web services
          3. Persisting the Bicycle class
          4. Changing BicycleRepository to use the OrmLite API
        6. Summary
      12. 5. Testing and Debugging AngularJS Applications
        1. Overview of testing AngularJS applications
          1. Introducing Node.js
          2. Setting up the Node.js environment
        2. Unit testing AngularJS components
          1. Installing Karma
          2. Configuring Karma
          3. Creating AngularJS unit tests with Jasmine
            1. Jasmine essentials
            2. Using the ngMock module for the first test
            3. Mocking remote server calls with $httpBackend
        3. Testing an AngularJS application end to end
          1. Installing Protractor
          2. Configuring Protractor
          3. Writing Protractor tests
        4. Testing web service endpoints
          1. Configuring self-hosted ServiceStack web services
          2. Adding BDD tests with xBehave.net
        5. Unit testing .NET code
        6. Techniques to debug AngularJS applications
        7. Support for HTML5 validation and older browsers such as Internet Explorer 8 and 9
        8. Summary
      13. 6. Advanced AngularJS Topics
        1. Internationalization and localization
          1. Using the ngLocale module
          2. Using the angular-dynamic-locale module
          3. Other internationalization-related topics
        2. Using AngularJS animations
        3. Working with remote web services
          1. Using JSONP
          2. Using CORS
        4. Template caching
        5. Summary
      14. Index