Search⌘ K
AI Features

Challenge: Use Service

Explore how to move hard-coded dietary preferences to a reusable Angular service within the signup component. Understand how to update unit tests accordingly, integrate the service using dependency injection, and maintain existing functionality without breaking tests.

Problem statement

Currently, the options for a user’s dietary preferences exist within SignupComponent as a hard-coded array. Without breaking any tests, see if you can move these diet preferences into a reusable service and update its corresponding test file to reflect your changes.

Playground

Below is the updated code. The template for service dietary-preferences has already been ...