{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/24082","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/24082/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/24082/comments","events_url":"https://api.github.com/repos/angular/angular/issues/24082/events","html_url":"https://github.com/angular/angular/issues/24082","id":325841870,"number":24082,"title":"New `provideIn: AppModule` syntax not working","user":{"login":"nicojs","id":1828233,"avatar_url":"https://avatars3.githubusercontent.com/u/1828233?v=4","gravatar_id":"","url":"https://api.github.com/users/nicojs","html_url":"https://github.com/nicojs","followers_url":"https://api.github.com/users/nicojs/followers","following_url":"https://api.github.com/users/nicojs/following{/other_user}","gists_url":"https://api.github.com/users/nicojs/gists{/gist_id}","starred_url":"https://api.github.com/users/nicojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicojs/subscriptions","organizations_url":"https://api.github.com/users/nicojs/orgs","repos_url":"https://api.github.com/users/nicojs/repos","events_url":"https://api.github.com/users/nicojs/events{/privacy}","received_events_url":"https://api.github.com/users/nicojs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-05-23T19:26:30Z","updated_at":"2018-05-24T02:20:17Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n\r\n```\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[x] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Performance issue\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n[ ] Other... Please describe:\r\n```\r\n\r\n## Current behavior\r\n\r\nWhen using the new `provideIn` syntax for injectable services as documented on https://angular.io/guide/dependency-injection#injectable-providers:\r\n\r\n```ts\r\n@Injectable({\r\n  providedIn: AppModule,\r\n})\r\nexport class HeroService {\r\n} \r\n```\r\n\r\nAnd request the service in a component:\r\n\r\n```ts\r\n@Component({})\r\nexport class AppComponent {\r\n  title = 'app';\r\n  constructor(s: HeroService) { }\r\n}\r\n\r\n```\r\n\r\nI get this error:\r\n\r\n```\r\nERROR Error: StaticInjectorError(AppModule)[AppComponent -> HeroService]: \r\n  StaticInjectorError(Platform: core)[AppComponent -> HeroService]: \r\n    NullInjectorError: No provider for HeroService!\r\n```\r\n\r\n## Expected behavior\r\n\r\nI would expect the service to be injected as singleton for the entire `AppModule`\r\n\r\n## Minimal reproduction of the problem with instructions\r\n\r\nhttps://stackblitz.com/edit/angular-ggecbg\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n\r\nI'm trying to figure out how to provide a service as a singleton in a single module using the new `provideIn` syntax. It is documented here: https://angular.io/guide/dependency-injection#injectable-providers but does not seem to work. Or I'm I making a mistake?\r\n\r\n## Environment\r\n\r\n<pre><code>\r\nAngular version: X.Y.Z\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\nBrowser:\r\n- [x] Chrome (desktop) version XX\r\n- [ ] Chrome (Android) version XX\r\n- [ ] Chrome (iOS) version XX\r\n- [ ] Firefox version XX\r\n- [ ] Safari (desktop) version XX\r\n- [ ] Safari (iOS) version XX\r\n- [ ] IE version XX\r\n- [ ] Edge version XX\r\n \r\nFor Tooling issues:\r\n- Node version: 10.1.0 <!-- run `node --version` -->\r\n- Platform:  windows\r\n- Angular CLI: 6.0.3\r\n- Angular: 6.0.2"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/391566240","html_url":"https://github.com/angular/angular/issues/24082#issuecomment-391566240","issue_url":"https://api.github.com/repos/angular/angular/issues/24082","id":391566240,"user":{"login":"trotyl","id":6059170,"avatar_url":"https://avatars0.githubusercontent.com/u/6059170?v=4","gravatar_id":"","url":"https://api.github.com/users/trotyl","html_url":"https://github.com/trotyl","followers_url":"https://api.github.com/users/trotyl/followers","following_url":"https://api.github.com/users/trotyl/following{/other_user}","gists_url":"https://api.github.com/users/trotyl/gists{/gist_id}","starred_url":"https://api.github.com/users/trotyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trotyl/subscriptions","organizations_url":"https://api.github.com/users/trotyl/orgs","repos_url":"https://api.github.com/users/trotyl/repos","events_url":"https://api.github.com/users/trotyl/events{/privacy}","received_events_url":"https://api.github.com/users/trotyl/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T02:20:17Z","updated_at":"2018-05-24T02:20:17Z","author_association":"CONTRIBUTOR","body":"Technically `providedIn: AppModule` definitely would not work, all components must be somehow imported (directly or indirectly) by `AppModule`, otherwise it won't showing in the app. So as long as `AppModule` being a dep of `SomeService`, then `SomeService` must not imported by any component to avoid circular dependency.\r\n\r\nNothing more than expected ES module semantics."}}
{"actor":{"display_login":"trotyl"}}