O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Angular for .NET Developers

Book Description

Build efficient web apps and deliver great results by integrating Angular and the .NET framework

About This Book

  • Become a more productive developer and learn to use frameworks that implement good development practices
  • Achieve advanced autocompletion, navigation, and refactoring in Angular using Typescript
  • Follow a gradual introduction to the concepts with a lot of examples and explore the evolution of a production-ready application

Who This Book Is For

If you are a .NET developer who now wants to efficiently build single-page applications using the new features that Angular 4 has to offer, then this book is for you. Familiarity of HTML, CSS, and JavaScript is assumed to get the most from this book.

What You Will Learn

  • Create a standalone Angular application to prototype user interfaces
  • Validate complex forms with Angular version 4 and use Bootstrap to style them
  • Build RESTful web services that work well with single-page applications
  • Use Gulp and Bower in Visual Studio to run tasks and manage JavaScript packages
  • Implement automatic validation for web service requests to reduce your boilerplate code
  • Use web services with Angular version 4 to offload and secure your application logic
  • Test your Angular version 4 and web service code to improve the quality of your software deliverables

In Detail

Are you are looking for a better, more efficient, and more powerful way of building front-end web applications? Well, look no further, you have come to the right place!

This book comprehensively integrates Angular version 4 into your tool belt, then runs you through all the new options you now have on hand for your web apps without bogging you down. The frameworks, tools, and libraries mentioned here will make your work productive and minimize the friction usually associated with building server-side web applications.

Starting off with building blocks of Angular version 4, we gradually move into integrating TypeScript and ES6. You will get confident in building single page applications and using Angular for prototyping components. You will then move on to building web services and full-stack web application using ASP.NET WebAPI. Finally, you will learn the development process focused on rapid delivery and testability for all application layers.

Style and approach

This book covers everything there is to know about getting well-acquainted with Angular 4 and .NET without bogging you down. Everything is neatly laid out under clear headings for quick consultation, offering you the information required to understand a concept immediately, with short, relevant examples of each feature.

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 code file.

Table of Contents

  1. 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. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Getting Started with Angular
    1. Introducing Angular
      1. The birth of AngularJS
      2. Why AngularJS?
      3. Angular 2
      4. The benefits of Angular 2
      5. The development process in Angular 2
        1. What is ECMAScript 6?
        2. What is a transpiler?
        3. What is TypeScript?
          1. The development process in JavaScript
          2. Development with a build-time transpiler
          3. Development with a runtime transpiler
          4. Transpiler options
      6. What happened to Angular 3?
      7. What's new in Angular ?
      8. Why Angular for .NET developers?
    2. Building a Hello World app with Angular
      1. Setting up the development environment
        1. Installing Visual Studio Code
        2. Installing Node.js
      2. Creating an Angular application
    3. The architecture of Angular
    4. Summary
  3. Angular Building Blocks - Part 1
    1. Modules (NgModules)
    2. Components
      1. The life cycle of a component
    3. Decorators and metadata
    4. Templates
      1. Inline templates
      2. Isolated templates
      3. The local template variable
    5. Binding
      1. One-way binding
      2. Interpolation binding
      3. Property binding
      4. Event binding
      5. Two-way binding
    6. Directives
      1. Structural directives
      2. Attribute directives
    7. Dependency injection
      1. Why dependency injection?
      2. The role of injectors
      3. Handling dependency injection in Angular
    8. Summary
  4. Angular Building Blocks - Part 2
    1. Forms
      1. Tools for forms
      2. Types of Angular forms
        1. Templete driven forms
        2. Model-driven forms
          1. Fundamental objects of model-driven forms
    2. Pipes
      1. Common pipes
        1. Pipe with parameters
      2. Chaining pipes
      3. Currency pipes
      4. Date pipes
      5. Uppercase and lowercase pipes
      6. JSON pipes
    3. AppComponent
    4. Routers
      1. The core concept of Component Routers
      2. Setting up a Component Router
      3. Configuring routes
      4. Router Outlet and Router Links
    5. Services
    6. Observables
    7. Summary
  5. Using TypeScript with Angular
    1. What is TypeScript?
    2. Basic types
      1. Boolean
      2. Number
      3. String
      4. Array
      5. Enum
      6. Any
      7. Void
    3. Interfaces
      1. Optional properties
      2. Function type interfaces
      3. Array type interfaces
      4. Class type interfaces
      5. Extending interfaces
      6. Hybrid type interface
    4. Classes
    5. Inheritance
      1. Inheritance in TypeScript
      2. Private/Public modifiers
      3. Accessors
      4. Static properties
    6. Modules
      1. Namespaces
      2. Modules
      3. Functions
      4. Optional and default parameters
      5. Rest parameters
    7. Generics
      1. Generic interfaces
      2. Generic classes
    8. Decorators
      1. Class decorators
      2. Method decorators
      3. Accessor decorators
      4. Property decorators
      5. Parameter decorators
    9. TypeScript and Angular
    10. Summary
  6. Creating an Angular Single-Page Application in Visual Studio
    1. Creating an ASP.NET core web application
    2. Adding client-side packages using NPM package manager
    3. Using Gulp to run tasks
    4. Adding Angular components and templates
      1. Configuring TypeScript compiler options
      2. Adding an Angular component
      3. Adding app module
      4. Adding an Angular component
      5. Adding a Todo class
      6. Adding a TodoService class
      7. Updating the AppComponent class
      8. Updating the AppModule
      9. Adding the AppComponent template
    5. Summary
  7. Creating ASP.NET Core Web API Services for Angular
    1. RESTful Web Services
    2. ASP.NET Web API Overview
      1. Why the ASP.NET Web API is a great fit for Angular
    3. Creating ASP.NET Web API services
      1. Adding and configuring an MVC service to the ASP.NET project
      2. Adding Web API Controller to an ASP.NET application
      3. Adding models to an ASP.NET application
      4. Adding DBContext to an ASP.NET application
    4. Using DB Migration
      1. Using Database Context in a Web API controller
    5. Integrating ASP.NET Core Web API with Angular application
      1. Updating a model in an Angular app
      2. Preparing Angular application
      3. Consuming Web API GET Action in TodoService
      4. Posting to the Web API from TodoService
      5. Calling the PUT action of the Web API to update a Todo item
      6. Calling the DELETE action of the Web API to delete a Todo item
      7. Updating the wrapper functions in TodoService
      8. Updating AppComponent
      9. Updating the AppComponent template
      10. Updating the index page
    6. Running the application
    7. Summary
  8. Creating an Application Using Angular, ASP.NET MVC, and Web API in Visual Studio
    1. Using ASP.NET MVC
    2. Combining routing for ASP.NET MVC, the ASP.NET Web API, and Angular
      1. Routing in ASP.NET MVC
        1. Adding ASP.NET MVC HomeController
      2. Routing for ASP.NET MVC
      3. Moving the content from the default page to the ASP.NET MVC view
      4. Routing in the ASP.NET Web API
      5. Routing in Angular
      6. Moving the Angular template to the ASP.NET MVC template
    3. Summary
  9. Testing Angular Applications
    1. Introducing Jasmine
    2. Testing Angular services
    3. Testing Angular components
      1. Writing Specs for AppComponent
      2. Running the specs or tests of AppComponent
    4. Unit testing a mock service
    5. Summary
  10. What s New in Angular and ASP.NET Core
    1. What's new in Angular
      1. Ahead-of-Time compilation
      2. Update on templates
      3. Introducing titlecase pipes
      4. Simplified parameter passing in HTTP
      5. Overriding templates in testing
    2. Introducing the Meta service
      1. New form validators
      2. Introducing ParamMap in router
    3. Introducing .NET Core 1.0
    4. Cross-platform development with the .NET Execution Environment
      1. The traditional .NET Framework
      2. Mono Cross-platform .NET Framework
      3. NuGet package manager
      4. CoreFx and CoreCLR in .NET Core
      5. Choosing a Framework
      6. The Dotnet Execution Environment- DNX
    5. Deployment options
      1. Publishing with Visual Studio
      2. Publishing with dotnet command-line interface
      3. Deploying to IIS
      4. Deploying to Microsoft Azure
      5. Deploying to Linux and macOS
    6. Summary