Value providers in Angular
In this recipe, you'll learn how to use value providers in Angular to provide constants and config values to your app. We'll start with the same example from the previous recipe, that is, EmployeeModule
and AdminModule
using the shared component named BucketComponent
. We will restrict the employee from deleting items from the bucket by using a value provider, so the employees won't even see the delete button.
Getting ready
The project that we are going to work with resides in the chapter03/start_here/ng-value-providers
path, which is inside the cloned repository. Perform the following steps:
- Open the project in Visual Studio Code.
- Open the Terminal, and run
npm install
to install the dependencies of the project. - Once done, run
ng serve -o
.This should open the app in a new browser tab.
- Click on the Login as Admin button. You should see something similar to the following screenshot: