all InfoSec news
Advanced Usage of Angular Dependency Injection
Feb. 6, 2024, 10:15 a.m. | Evgeniy OZ
DEV Community dev.to
inject()
A long time ago in a galaxy far, far away, we were declaring dependencies of our Angular components in the constructor:
@Component({
selector: 'app-example',
template: ``
})
export class ExampleComponent {
constructor(private readonly authService: AuthenticationService) {
}
}
And our services were declaring their dependencies in the constructor:
@Injectable({ providedIn: "root" })
class AuthenticationService {
constructor(private readonly http: HttpClient) {
}
getCurrentUserProfile(): Observable<UserProfile> {
return this.http.get<UserProfile>('/user/profile');
}
}
But then magical inject() was brought to our world, and we …
advanced angular app class components dependencies dependency export far galaxy inject injection private root services template
More from dev.to / DEV Community
Jobs in InfoSec / Cybersecurity
Senior Security Engineer - Detection and Response
@ Fastly, Inc. | US (Remote)
Application Security Engineer
@ Solidigm | Zapopan, Mexico
Defensive Cyber Operations Engineer-Mid
@ ISYS Technologies | Aurora, CO, United States
Manager, Information Security GRC
@ OneTrust | Atlanta, Georgia
Senior Information Security Analyst | IAM
@ EBANX | Curitiba or São Paulo
Senior Information Security Engineer, Cloud Vulnerability Research
@ Google | New York City, USA; New York, USA