Olá,
Gostaria de saber qual é o papel do UserService no código da aula:
import { Directive, ElementRef, Input, OnInit, Renderer } from '@angular/core';
import { UserService } from 'src/app/core/user/user.service';
import { Photo } from '../../photo/photo';
@Directive({
selector: '[photoOwnerOnly]'
})
export class PhotoOwnerOnlyDirective implements OnInit {
@Input() ownedPhoto: Photo;
constructor(private element: ElementRef<any>,
private renderer: Renderer,
private UserService: UserService) {}
ngOnInit(): void {
this.UserService
.getUser()
.subscribe(user => {
if(!user || user.id != this.ownedPhoto.userId)
this.renderer.setElementStyle(this.element.nativeElement, 'display', 'none')
})
}
}