Injectable cannot pass the optional parameter providedIn

In the example of the http section of the Angular6 official document, in heroes.service.ts, @ Injectable ({providedIn: "root"}) has been reporting an error
error message

before export.
ERROR in src/app/hero.service.ts(15,2): error TS2554: Expected 0 arguments, but got 1.

Injectable in api has an optional parameter providedIn

I don"t know why, but who has encountered this problem?


turns out to be a problem with angular. Angular5.x is referenced in the project, and there will be no errors if you upgrade to 6.x.


this providerIn parameter was introduced only in 6.

Menu