0

I am trying to modify the css of a child component ( app-dashboard-menu ) from the parent ( app-dashboard-router )

In dash-router:

 @ViewChild('menu') el!: ElementRef;
  constructor(private renderer: Renderer2) { }

  doSomething(){
    this.renderer.setStyle(this.el.nativeElement, 'background', 'yellow');
  }

In component dash-menu:

<div class="machin" #menu>
  ....
</div>

--> and I have this error: Cannot read properties of undefined (reading 'nativeElement')

Orel M
  • 45
  • 6

0 Answers0