Book Image

Learning Angular for .NET Developers

By : Rajesh Gunasundaram
Book Image

Learning Angular for .NET Developers

By: Rajesh Gunasundaram

Overview of this book

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.
Table of Contents (16 chapters)
Title Page
About the Author
About the Reviewers
Customer Feedback

Integrating ASP.NET Core Web API with Angular application

In the preceding section, we added and modified the Web API controller and introduced methods for HTTP verbs to deal with the Todo items. Now, let's modify our Angular code to consume all the Web API methods to manage the Todo items.

Updating a model in an Angular app

First, we need to add the id property to Todo.ts in an Angular app to hold the ID of the Todo item received from the API. So, the updated Todo.ts will look as follows:

export class Todo { 
    id: number; 
    title: string; 
    completed: boolean; 
    constructor(id: number, title: string, completed: 
    boolean) { = id; 
        this.title = title; 
        this.completed = completed; 
    set isCompleted(value: boolean) { 
        this.completed = value; 

The constructor takes three arguments: id, title, and completed, and assigns them to the id, title, and completed properties respectively, accessing them using the this keyword...