{"action":"opened","issue":{"url":"https://api.github.com/repos/ionic-team/ionic-v3/issues/555","repository_url":"https://api.github.com/repos/ionic-team/ionic-v3","labels_url":"https://api.github.com/repos/ionic-team/ionic-v3/issues/555/labels{/name}","comments_url":"https://api.github.com/repos/ionic-team/ionic-v3/issues/555/comments","events_url":"https://api.github.com/repos/ionic-team/ionic-v3/issues/555/events","html_url":"https://github.com/ionic-team/ionic-v3/issues/555","id":385611857,"node_id":"MDU6SXNzdWUzODU2MTE4NTc=","number":555,"title":"StaticInjectorError sometimes thrown when injecting provider into component","user":{"login":"ionitron-bot[bot]","id":35967572,"node_id":"MDM6Qm90MzU5Njc1NzI=","avatar_url":"https://avatars1.githubusercontent.com/in/8640?v=4","gravatar_id":"","url":"https://api.github.com/users/ionitron-bot%5Bbot%5D","html_url":"https://github.com/apps/ionitron-bot","followers_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/followers","following_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/repos","events_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/ionitron-bot%5Bbot%5D/received_events","type":"Bot","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-29T07:58:33Z","updated_at":"2018-11-29T07:58:33Z","closed_at":null,"author_association":"NONE","body":"_Original issue by @bathetrade on [2018-02-03T00:14:27Z](https://github.com/ionic-team/ionic/issues/13946)_\n\n**Ionic version:**  (check one with \"x\")\r\n(For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)\r\n[ ] **2.x**\r\n[X] **3.x**\r\n[ ] **4.x**\r\n\r\n**I'm submitting a ...**  (check one with \"x\")\r\n[X] bug report\r\n[ ] feature request\r\n\r\n**Current behavior:**\r\nStaticInjectorError[TestProvider] is thrown when adding an empty provider (TestProvider) to a blank Ionic project, and injecting it into the home page component. Everything appears set up correctly, i.e., app.module imports TestProvider and puts it in the provider list, and the home page imports TestProvider and injects it into the constructor. \r\n\r\nNote that, in one round of testing, three unique providers were created with identical code. One of them consistently worked, while the other two consistently produced the error. At any given time, only one of the providers was being injected in the home page component; however, all three were being imported.\r\n\r\nAll of the providers were generated with `ionic generate provider <ClassnameProvider>`\r\n\r\nAll paths to the provider are correct.\r\n\r\n```\r\nUncaught (in promise): Error: StaticInjectorError[TestProvider]: \r\n  StaticInjectorError[TestProvider]: \r\n    NullInjectorError: No provider for TestProvider!\r\n_NullInjector.prototype.get@http://localhost:8100/build/vendor.js:1276:19\r\nresolveToken@http://localhost:8100/build/vendor.js:1564:17\r\ntryResolveToken@http://localhost:8100/build/vendor.js:1506:16\r\nStaticInjector.prototype.get@http://localhost:8100/build/vendor.js:1377:20\r\nresolveToken@http://localhost:8100/build/vendor.js:1564:17\r\ntryResolveToken@http://localhost:8100/build/vendor.js:1506:16\r\nStaticInjector.prototype.get@http://localhost:8100/build/vendor.js:1377:20\r\nresolveNgModuleDep@http://localhost:8100/build/vendor.js:10938:12\r\nNgModuleRef_.prototype.get@http://localhost:8100/build/vendor.js:12159:16\r\nresolveDep@http://localhost:8100/build/vendor.js:12655:12\r\ncreateClass@http://localhost:8100/build/vendor.js:12519:85\r\ncreateDirectiveInstance@http://localhost:8100/build/vendor.js:12364:37\r\ncreateViewNodes@http://localhost:8100/build/vendor.js:13802:53\r\ncreateRootView@http://localhost:8100/build/vendor.js:13692:5\r\ncallWithDebugContext@http://localhost:8100/build/vendor.js:15093:39\r\ndebugCreateRootView@http://localhost:8100/build/vendor.js:14394:12\r\nComponentFactory_.prototype.create@http://localhost:8100/build/vendor.js:11313:37\r\nComponentFactoryBoundToModule.prototype.create@http://localhost:8100/build/vendor.js:4275:16\r\nNavControllerBase.prototype._viewInit@http://localhost:8100/build/vendor.js:48293:27\r\nNavControllerBase.prototype._nextTrns/<@http://localhost:8100/build/vendor.js:48106:17\r\nF</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14974\r\nonInvoke@http://localhost:8100/build/vendor.js:4982:24\r\nF</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14901\r\nF</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:10124\r\nf/<@http://localhost:8100/build/polyfills.js:3:20240\r\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649\r\nonInvokeTask@http://localhost:8100/build/vendor.js:4973:24\r\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562\r\nF</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815\r\no@http://localhost:8100/build/polyfills.js:3:7887\r\n\r\nStack trace:\r\nc@http://localhost:8100/build/polyfills.js:3:19752\r\nu/<@http://localhost:8100/build/polyfills.js:3:19174\r\nNavControllerBase.prototype._fireError@http://localhost:8100/build/vendor.js:48075:13\r\nNavControllerBase.prototype._failed@http://localhost:8100/build/vendor.js:48068:9\r\nNavControllerBase.prototype._nextTrns/<@http://localhost:8100/build/vendor.js:48115:53\r\nF</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14974\r\nonInvoke@http://localhost:8100/build/vendor.js:4982:24\r\nF</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14901\r\nF</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:10124\r\nf/<@http://localhost:8100/build/polyfills.js:3:20240\r\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649\r\nonInvokeTask@http://localhost:8100/build/vendor.js:4973:24\r\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562\r\nF</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815\r\no@http://localhost:8100/build/polyfills.js:3:7887\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors occur.\r\n\r\n**Steps to reproduce:**\r\n1. Create a blank Ionic project. `ionic start TestProject blank`\r\n2. Add a provider. `ionic generate provider TestProvider`\r\n3. Inject the provider into the home page component's constructor.\r\n4. Sometimes, the error occurs. If it doesn't occur, continue adding new providers and injecting them into the home page component, replacing the previously injected providers. (The home page component constructor only contains one user-defined provider at a time.)\r\n\r\n**Related code:**\r\n\r\nTestProject/src/app/app.module.ts:\r\n```\r\nimport { BrowserModule } from '@angular/platform-browser';\r\nimport { ErrorHandler, NgModule } from '@angular/core';\r\nimport { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';\r\nimport { SplashScreen } from '@ionic-native/splash-screen';\r\nimport { StatusBar } from '@ionic-native/status-bar';\r\n\r\nimport { MyApp } from './app.component';\r\nimport { HomePage } from '../pages/home/home';\r\nimport { TestProvider } from '../providers/test/test';\r\n\r\n@NgModule({\r\n  declarations: [\r\n    MyApp,\r\n    HomePage\r\n  ],\r\n  imports: [\r\n    BrowserModule,\r\n    IonicModule.forRoot(MyApp)\r\n  ],\r\n  bootstrap: [IonicApp],\r\n  entryComponents: [\r\n    MyApp,\r\n    HomePage\r\n  ],\r\n  providers: [\r\n    StatusBar,\r\n    SplashScreen,\r\n    {provide: ErrorHandler, useClass: IonicErrorHandler},\r\n    TestProvider\r\n  ]\r\n})\r\nexport class AppModule {}\r\n```\r\n\r\nTestProject/src/pages/home/home.ts:\r\n```\r\nimport { Component } from '@angular/core';\r\nimport { NavController } from 'ionic-angular';\r\nimport { TestProvider } from '../../providers/test/test';\r\n\r\n@Component({\r\n  selector: 'page-home',\r\n  templateUrl: 'home.html'\r\n})\r\nexport class HomePage {\r\n\r\n  constructor(public navCtrl: NavController, public test: TestProvider ) {\r\n  }\r\n}\r\n```\r\n\r\nTestProject/src/providers/test/test.ts:\r\n```\r\nimport { Injectable } from '@angular/core';\r\n\r\n/*\r\n  Generated class for the TestProvider provider.\r\n\r\n  See https://angular.io/guide/dependency-injection for more info on providers\r\n  and Angular DI.\r\n*/\r\n@Injectable()\r\nexport class TestProvider {\r\n\r\n  constructor() {\r\n    console.log('Hello TestProvider Provider');\r\n  }\r\n}\r\n```\r\n\r\npackage.json:\r\n```\r\n{\r\n  \"name\": \"ProviderNamingBug\",\r\n  \"version\": \"0.0.1\",\r\n  \"author\": \"Ionic Framework\",\r\n  \"homepage\": \"http://ionicframework.com/\",\r\n  \"private\": true,\r\n  \"scripts\": {\r\n    \"clean\": \"ionic-app-scripts clean\",\r\n    \"build\": \"ionic-app-scripts build\",\r\n    \"lint\": \"ionic-app-scripts lint\",\r\n    \"ionic:build\": \"ionic-app-scripts build\",\r\n    \"ionic:serve\": \"ionic-app-scripts serve\"\r\n  },\r\n  \"dependencies\": {\r\n    \"@angular/common\": \"5.0.3\",\r\n    \"@angular/compiler\": \"5.0.3\",\r\n    \"@angular/compiler-cli\": \"5.0.3\",\r\n    \"@angular/core\": \"5.0.3\",\r\n    \"@angular/forms\": \"5.0.3\",\r\n    \"@angular/http\": \"5.0.3\",\r\n    \"@angular/platform-browser\": \"5.0.3\",\r\n    \"@angular/platform-browser-dynamic\": \"5.0.3\",\r\n    \"@ionic-native/core\": \"4.4.0\",\r\n    \"@ionic-native/splash-screen\": \"4.4.0\",\r\n    \"@ionic-native/status-bar\": \"4.4.0\",\r\n    \"@ionic/storage\": \"2.1.3\",\r\n    \"ionic-angular\": \"3.9.2\",\r\n    \"ionicons\": \"3.0.0\",\r\n    \"rxjs\": \"5.5.2\",\r\n    \"sw-toolbox\": \"3.6.0\",\r\n    \"zone.js\": \"0.8.18\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"@ionic/app-scripts\": \"3.1.8\",\r\n    \"typescript\": \"2.4.2\"\r\n  },\r\n  \"description\": \"An Ionic project\"\r\n}\r\n```\r\n\r\n**Other information:**\r\n\r\n[Stack Overflow question](https://stackoverflow.com/questions/48592407/staticinjectorerror-when-adding-simple-provider-to-blank-ionic-project-and-injec)\r\n\r\n**Ionic info:** (run `ionic info` from a terminal/cmd prompt and paste output below):\r\n\r\n```\r\ncli packages: (C:\\Users\\Derek\\AppData\\Roaming\\npm\\node_modules)\r\n\r\n    @ionic/cli-utils  : 1.19.1\r\n    ionic (Ionic CLI) : 3.19.1\r\n\r\nlocal packages:\r\n\r\n    @ionic/app-scripts : 3.1.8\r\n    Ionic Framework    : ionic-angular 3.9.2\r\n\r\nSystem:\r\n\r\n    Node : v8.9.4\r\n    npm  : 5.6.0\r\n    OS   : Windows 10\r\n\r\nMisc:\r\n\r\n    backend : pro\r\n\r\n```\r\n\r\n\r\n"}}
{"actor":{"display_login":"ionitron-bot"}}