5 - Angular Services
In this section we discuss angular service
1. Generate a new angular service
Run the following command to make a new service in the auth lib
2. Add login method and http post for the login
Add HttpClientModule to Auth Module
libs/auth/src/lib/auth.module.ts
Add login call to a local server
libs/auth/src/lib/services/auth/auth.service.ts
3. Update Login component to call the service
libs/auth/src/containers/login/login.component.ts
Note the .subscribe() is needed to make sure the observer is registered with the observable returned from our AuthService.
Later in the workshop we will learn to use NgRx to get entities from a server, but for now this is normal angular code without NgRx
4. Attempt to login with default users
To login as an admin use the below credentials and this will return a fake admin token. Note this is in no means an attempt to make a production authentication service it is purely to give us mock data from a real angular HTTP request.
To login as a non-admin use the below credentials
Last updated