-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: difeatureIssue that requests a new featureIssue that requests a new feature
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
When providing a Service in a component, inject() triggers NullInjectorError when called within runInContext :
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [Service],
})
export class AppComponent {
public constructor(injector: EnvironmentInjector, service: Service) {
console.log(service); // OK
console.log(inject(Service)); //OK
setTimeout(() => {
injector.runInContext(() => {
console.log(inject(Service)); //KO
});
}, 100);
}
}This does not happen
- if the service is
providedIn:'root' - if the service is provided in the module
Please provide a link to a minimal reproduction of the bug
Please provide the environment you discovered this bug in (run ng version)
Angular 14.2.3
antischematic, samuelfernandez, ghostlytalamaur, kukjevov, Jonathan002 and 2 more
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: difeatureIssue that requests a new featureIssue that requests a new feature