Solution: Practice with Directives

Let’s compare our results against the expected outcome.

We'll cover the following

Explanation

The only thing we need to change is the directive’s selector. We can match all elements with the class name header as follows:

@Directive({
  selector: '.header'
})
export class BoldDirective {

  constructor(el: ElementRef) {
    el.nativeElement.style.fontWeight = 'bold';
  }
}

Solution

Here’s an example of what the solution for this task may look like:

Get hands-on with 1400+ tech skills courses.