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

Information Security Engineers

@ D. E. Shaw Research | New York City

Technology Security Analyst

@ Halton Region | Oakville, Ontario, Canada

Senior Cyber Security Analyst

@ Valley Water | San Jose, CA

Sr. Staff Firmware Engineer – Networking & Firewall

@ Axiado | Bengaluru, India

Compliance Architect / Product Security Sr. Engineer/Expert (f/m/d)

@ SAP | Walldorf, DE, 69190

SAP Security Administrator

@ FARO Technologies | EMEA-Portugal