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
Switching to Angular

You're reading from   Switching to Angular Align with Google's long-term vision for Angular version 5 and beyond

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher
ISBN-13 9781788620703
Length 280 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Minko Gechev Minko Gechev
Author Profile Icon Minko Gechev
Minko Gechev
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Switching to the One Angular FREE CHAPTER 2. Get Going with Angular 3. The Building Blocks of an Angular Application 4. TypeScript Crash Course 5. Getting Started with Angular Components and Directives 6. Dependency Injection in Angular 7. Working with the Angular Router and Forms 8. Explaining Pipes and Communicating with RESTful Services 9. Tooling and Development Experience

Writing generic code using type parameters

In the beginning of the section on using static typing, we mentioned the type parameters. In order to get a better understanding of them, let's begin with an example. Let's suppose that we want to implement the classical data structure BinarySearchTree. Let's define its interface using a class without applying any method implementations:

class Node { 
  value: any; 
  left: Node; 
  right: Node; 
} 
 
class BinarySearchTree { 
  private root: Node; 
  insert(any: value): void { /* ... */ } 
  remove(any: value): void { /* ... */ } 
  exists(any: value): boolean { /* ... */ } 
  inorder(callback: {(value: any): void}): void { /* ... */ } 
} 

In the preceding snippet, we defined a class called Node. The instances of this class represent the individual nodes in our tree. Each node has a left and right child nodes and a value...

lock icon The rest of the chapter is locked
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 AU $24.99/month. Cancel anytime