Angular 7 exercise for learning services and dependency injection.
The Doggo Shop is an app where lovers of dogs can come and browse a collection fo lovable best friends and make lists of their favorite doggos. Your task is to build this dream come true!
Services manage the data in your app. Any service can be made available to any component at any time. Use services to manage the Dog collection. The service should:
Start by displaying the collection fo dogs before you work on the likes and favorites.
The dog information for this app is stored in a JSON file in the project. You’ll need to parse it to create a browsable collection of dogs.
The localStorage
object is built into browsers to allow applications to store small stores of data. For example, a common use case for this type of storage might include shopping carts that remember what you placed in them even if you leave the page.
There’s also sessionStorage
which only lives as long as the browser tab remains open. Closing the tab clears the storage.
Use these tools to persist data in your application.
Finish this application. The main features:
IMPORTANT:
tsconfig.json
is has been configured with 3 properties to handle JSON files:resolveJsonModule, esModuleInterop, and allowSyntheticDefaultImports
.
With this configured, JSON files can be imported as follows: import jsonName from path/to/json;
.
DogsService
dogData
to DogService
get()
method to retrieve dogs by their idall()
method to retrieve all dogsDogListComponent
DogService
getAll()
which returns all the dogs.dogs
with value this.getAll()
Dog
(class)