It's not my first month with angular so please do not say things like "be sure if you import the service". I can call methods from the service from any component but from app.component.
No errors when importing
import { GeneralService } from './services/generalservice.service';
No errors when declaring
private generalService: GeneralService
Even if i do in @Component({......})
providers: [GeneralService]
No errors in command line... But for some reason browser says..
Uncaught Error: Can't resolve all parameters for GeneralService: ([object Object], [object Object], [object Object], ?).
at syntaxError (compiler.es5.js:1690)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver._getDependenciesMetadata (compiler.es5.js:15765)
at .............
I don't even call any function to see an error. It shows right after declaring the service in the constructor.
I just finished second Starbucks's Venti-Americano. But still no light in my brain about this... so please tell me something guys. Thanks.
如果要注入到服务AppComponent
,该服务需要被提供@Component(...)
的AppComponent
或@NgModule(...)
非延迟加载的模块。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.