:clipboard: This is a data-driven app that stores and displays a list of heroes, edits their details and allows navigation of the data using different views.
TypeScriptMIT
β‘ Angular Tour of Heroes
This is a data-driven app that stores and displays a list of heroes, edits their details and allows navigation of the data using different views.
Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
π» Code Examples - from Angular Tour of Heroes code
in-memory-data-service file
// Angular in-memory web api module// This provides the InMemoryDataService as a parameter for the .forRoot method of the InMemoryServiceiModule module.// Overrides the createDb() method.import{InMemoryDbService}from'angular-in-memory-web-api';import{Hero}from'./hero';import{Injectable}from'@angular/core';
@Injectable({providedIn: 'root',})exportclassInMemoryDataServiceimplementsInMemoryDbService{createDb(){constheroes=[{id: 11,name: 'Mr. Nice'},{id: 12,name: 'Narco'},{id: 13,name: 'Bombasto'},{id: 14,name: 'Celeritas'},{id: 15,name: 'Magneta'},{id: 16,name: 'RubberMan'},{id: 17,name: 'Dynama'},{id: 18,name: 'Dr IQ'},{id: 19,name: 'Magma'},{id: 20,name: 'Tornado'}];return{heroes};}// Overrides the genId method to ensure that a hero always has an id.// If the heroes array is empty,// the method below returns the initial number (11).// if the heroes array is not empty, the method below returns the highest// hero id + 1.genId(heroes: Hero[]): number{returnheroes.length>0 ? Math.max(...heroes.map(hero=>hero.id))+1 : 11;}constructor(){}}
π Features
CRUD operations: heroes can be created, read, updated (name only) and deleted from a 'My Heroes' list.
Clicking on a hero routes to a hero details page.
A 'Messages' list records fetching and deleting of heroes from the My Heroes list.
π Status & To-Do List
Status: Working app with in-memory database storage of heroes.