Cannot find module './in-memory-data-service' in tour of heroes for Angular2

前端 未结 13 972
我在风中等你
我在风中等你 2021-02-06 21:49

I am trying to work through the Angular2 tour of heroes app, and am running into bugs on the Http section of the tutorial.

At first I was getting the error:

         


        
13条回答
  •  情深已故
    2021-02-06 22:31

    ng generate service InMemoryData --module=app
    

    Will create the src/app/in-memory-data.service.ts file. Then add the code listed in the tutorial and it will work. AFAIK they don't even imply that in the tutorial so don't feel bad. In fact what they say is

    The forRoot() configuration method takes an InMemoryDataService class that primes the in-memory database.

    The Tour of Heroes sample creates such a class src/app/in-memory-data.service.ts

    Which is gibberish and wrong.

提交回复
热议问题