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

前端 未结 13 1000
我在风中等你
我在风中等你 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:36

    For Angular5 tutorial and angular-in-memory-web-api@0.5.3:

    Add new file "in-memory-data.service.ts" to your root directory with this contents:

    import { InMemoryDbService } from 'angular-in-memory-web-api';
    
    export class InMemoryDataService  implements InMemoryDbService {
    createDb() {
        let heroes = [
            { id: 1, name: 'Windstorm' },
            { id: 2, name: 'Bombasto' },
            { id: 3, name: 'Magneta' },
            { id: 4, name: 'Tornado' }
        ];
        return { heroes };
    }
    }
    

提交回复
热议问题