Skip to content

Commit 61a36a1

Browse files
authored
Merge pull request #175 from akanagar/angular-mock-service
created angular mock service
2 parents ae4c58e + 79f641c commit 61a36a1

12 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* A data table with all the elements
2+
A data table with CRUD operations is very useful (in our case we only view details or delete an item, but they illustrate two important things: the details view shows how to navigate and consume a parametric route, the delete action shows how to invoke service operations over the loaded data - this means that the component is reusable and when the data comes with an API, only the service will need it’s implementation changed)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* A details page that reads a route parameter and displays the details of the element.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The app presents 3 pages as follows:
2+
3+
* A leader board with the top 3 elements
4+
A leader board can be understood as "the most popular items in a set", "the latest updated items", "you favorite items" etc.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Let’s consider a 'box of data' represented in JSON. Physically this means a folder with some JSON/TS files in it. They are located in the app/mock folder. The example uses only one mock data file. The file is typed according to our data model.
2+
3+
The model is represented by the interfaces we make. These interfaces describe the data structures we will use in our application. In this example, there is one data model, corresponding with the 'type' of data that was mocked. In the models folder you will find the .ts script file that describes chemical elements. The corresponding mock file defines a set is chemical element objects, in accordance to our interface definition.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
A service is an injectable logic that can be consumed by all the components that need it. It can carry manipulation functions and ,in our case, fetch data from a provider.
2+
Inside the Angular App, an Injector gives access to each component to their required services. It’s good coding practice to use a distinct service to each data type you want to manipulate. The type is described in a interface.
3+
4+
Here we simply fetch and display the data of elements and their details.
70.8 KB
Loading
39.7 KB
Loading
49.6 KB
Loading
45.6 KB
Loading
34.2 KB
Loading

0 commit comments

Comments
 (0)