Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
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

Defining generic views with TemplateRef

We are already familiar with the concepts of inputs, content children, and view children, and we also know when we can get a reference to them in the component's life cycle. Now, we will combine them and introduce a new concept: TemplateRef.

Let's take a step back and take a look at the last to-do application we developed earlier in this chapter. In the following screenshot, you can see what its UI looks like:

Figure 9

If we take a look at its implementation in ch5/inputs-outputs/app.ts, we'll see that the template used to render the individual to-do items is defined inside the template of the entire to-do application.

What if we want to use a different layout to render the to-do items? We can do this by creating another component called Todo, which encapsulates the responsibility of rendering them. Then, we can define separate...

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 $19.99/month. Cancel anytime