Implementing a user service with GET
In order to implement a user profile, we need a service that can perform CRUD operations on IUser. We will be creating a user service that implements the following interface:
export interface IUserService {
getUser(id: string): Observable<IUser>
updateUser(id: string, user: IUser): Observable<IUser>
getUsers(
pageSize: number,
searchText: string,
pagesToSkip: number
): Observable<IUsers>
}
Before creating the service, make sure to start the lemon-mart-server and set your application's AuthMode to CustomServer.
In this section, we will implement the getUser and updateUser functions. We will implement getUsers in Chapter 12, Recipes – Master/Detail, Data Tables, and NgRx, to support pagination with a data table.
Start by creating the user service:
- Create a
UserServiceundersrc/app/user/user - Declare the
IUserServiceinterface from the preceding snippet...