What is angular2-in-memory-web-api? I've seen references to it in the angular.io documentation but my code seems to work without it.
It's used for demos only:
For example the get heroes scenario
would work without webapi, just loading demo data from JSON file, but we want to save data too. We can't save changes to a JSON file. We need a web API server.
The in-memory web api
is not part of the Angular core. It's an optional service in its own angular2-in-memory-web-api
library that we installed with npm (see package.json) and registered for module loading by SystemJS (see systemjs.config.js)
The in-memory web API gets its data from a custom application class with a createDb()
method that returns a map whose keys are collection names and whose values are arrays of objects in those collections.
Here the Javadoc from the InMemoryDataService on Github:
Simulate the behavior of a RESTy web api backed by the simple in-memory data store provided by the injected InMemoryDataService service. [...]
You can use the API to create a demo application in Angular2. The service provides an API which let you simulate a REST-API. It's only an optional package and your app will work without it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With