Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Angular practice exercises with solutions

        Start with the required behavior. Implement the task, change the input, then check whether the same rule still holds. Each exercise includes a solution approach and a case that defeats a shortcut.

        Checked 22 November 2026

        Zero quantities and totals

        Build a quantity selector with signal(0) and a unit price of 12.

        Show a total of 0 initially, then 36 after three increments. Derive the total with computed; changing the price must also update it. A copied number calculated only during initialization becomes stale.

        Read the signal with quantity() in the template. Update its value through set or update. The signals guide explains the difference between stored and derived state.

        An empty filtered list

        Display active orders using @for, with a stable order ID in track. Add an empty message with @empty. Start with two active orders, then filter both out: the list must disappear and the empty message must appear once. Test reordered rows as well as an empty source array.

        Compute the filtered collection first. An always-visible message, or tracking a changing list only by position, misses part of the requirement.

        A component event with an ID

        Give a child card a required order input and a selected output. Clicking its button must send the order’s ID to the parent. Two cards with the same label but different IDs must produce different results.

        The parent owns the selection. Emit the ID and update that parent state in its event binding; changing only the child’s display doesn’t complete the task.

        A form with a valid zero

        Create a form for a name and a nonnegative quantity. An empty name is invalid; a quantity of 0 is valid. Block an invalid submission and show the error after interaction. Test a negative quantity and a corrected form as separate cases.

        In a reactive form, put the rules on the control model. In a template-driven form, attach the corresponding directives. Test the model and the rendered message rather than treating any falsy value as missing.

        A route before the fallback

        Define an order detail route and a wildcard not-found route. A known URL must render the detail page, and an unknown URL must render the fallback. Keep the wildcard last: Angular checks routes in order.

        A late response

        For a search interface, start request A and then request B. Let B finish first. The final display must keep B’s results when A finishes. A latest-request stream can use switchMap; also give loading, empty and error states distinct displays.

        Use controlled responses in a test so completion order is deliberate. Then change the query again after an error to confirm the stream still works. Explain these decisions with the Angular interview questions and practice working components in the Angular course.

        Sources

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        New accounts get 12 hours of full access: every course, unit, project and exam. The clock starts when you open your first lesson.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.