O'Reilly logo

Switching to Angular - Third Edition by Minko Gechev

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

View child versus content child

Although both concepts sound similar, they have quite different semantics. In order to understand them better, let's take a look at the following example:

// ch5/view-child-content-child/app.ts 
@Component({ 
  selector: 'user-badge', 
  template: '...' 
}) 
class UserBadge {} 
 
@Component({ 
  selector: 'user-rating', 
  template: '...' 
}) 
class UserRating {} 

Here, we've defined two components: UserBadge and UserRating. Let's define a parent component, which comprises both the components:

@Component({ 
  selector: 'user-panel', 
  template: '<user-badge></user-badge>'
}) 
class UserPanel {...} 

Note that the template of the view of UserPanel contains only the UserBadge component's selector. Now, let's use the UserPanel component ...

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

Start Free Trial

No credit card required