Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Angular for .NET Developers

You're reading from   Learning Angular for .NET Developers Develop dynamic .NET web applications powered by Angular 4

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781785884283
Length 248 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rajesh Gunasundaram Rajesh Gunasundaram
Author Profile Icon Rajesh Gunasundaram
Rajesh Gunasundaram
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Getting Started with Angular 2. Angular Building Blocks - Part 1 FREE CHAPTER 3. Angular Building Blocks - Part 2 4. Using TypeScript with Angular 5. Creating an Angular Single-Page Application in Visual Studio 6. Creating ASP.NET Core Web API Services for Angular 7. Creating an Application Using Angular, ASP.NET MVC, and Web API in Visual Studio 8. Testing Angular Applications 9. What s New in Angular and ASP.NET Core

Decorators and metadata


As you saw in the last section, we define JavaScript plain classes for a component, and we annotate it with some information to inform the Angular framework that this class is a component.

We leverage the Typescript syntax and attach the classes with metadata using the decorator feature. To make a class as a component, we add the @Component decorator, as shown in the following code:

@Component({...})
export class FirstComponent {...}

As you can see, the code snippet shows that the FirstComponent class has been decorated as a component.

Now, let's attach metadata to the FirstComponent class using the decorator syntax:

@Component({ 
   selector: 'first-component', 
   templateUrl: 'app/first.component.html' 
}) 
export class FirstComponent {...} 

Here, we have added metadata, such as a selector and templateUrl. The selector metadata configured in the component tells Angular to create the instance of a component when it encounters the <first-controller> markup:

<first...
You have been reading a chapter from
Learning Angular for .NET Developers
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781785884283
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image