Bacancy Bacancy
  • Our Engagement Models

    We offer flexible engagement models tailored to your project scope and timeline.

    Software Development Outsourcing
    Staff Augmentation
    Dedicated Teams
    Engagement Models

    High-Quality, Affordable IT Outsourcing

    Explore All Services

    AI & ML

    • AI Strategy & Roadmap
    • AI Development
    • Generative AI
    • AI Agent Development
    • Machine Learning
    • Computer Vision
    • LLM Development
    • RAG Development

    Data

    • Data Engineering
    • Data Analytics & BI
    • Data Science
    • Data Warehouse
    • Data Lake
    • Data Governance

    Cloud

    • Cloud Consulting
    • Cloud Migration
    • AWS Services
    • Azure Services
    • GCP Services
    • Kubernetes
    • DevOps

    Product Engineering

    • Full Stack Development
    • Custom Software Development
    • SaaS Development
    • App Modernization
    • Mobile App Development
    • Web Development
    • UI/UX Design

    Platforms

    • Salesforce
    • SAP
    • ServiceNow
    • Microsoft Dynamics
    • Snowflake
    • Databricks
  • Why Bacancy

    14+ years building domain-specific products for regulated and high-growth industries worldwide.

    Global delivery, every time zone

    Global delivery, every time zone

    1050+ vetted engineers

    1050+ vetted engineers

    Onboard in 48 hours

    Onboard in 48 hours

    Explore Our Case Studies

    Industries

    • Healthcare
    • Finance
    • eCommerce
    • Logistics
    • Fintech
    • Real Estate
    • Education
    • Insurance
    How Bacancy Built a Custom Epic EHR Solution to Automate Clinical Workflows

    How Bacancy Built a Custom Epic EHR Solution to Automate Clinical Workflows

    Read case study
  • About.

    1050+ world-class tech experts. One standard: customer satisfaction.

    About Company

    About Company

    • About Us
    • Leadership Team
    • Customer Reviews
    • Infrastructure
    • Our Locations
    • Partnership

    Resources

    • Press Room
    • Blog
    • Insights
    ISO/IEC 27001:2022 Certified

    ISO/IEC 27001:2022 Certified

    Built for enterprise security and compliance.

    Get Quote
  • Technologies
  • Customer Stories
  • Contact Us
Find a Developer
book a 30 min call
  • AI Strategy & Roadmap
  • AI Development
  • Generative AI
  • AI Agent Development
  • Machine Learning
  • Computer Vision
  • LLM Development
  • RAG Development
  • Data Engineering
  • Data Analytics & BI
  • Data Science
  • Data Warehouse
  • Data Lake
  • Data Governance
  • Cloud Consulting
  • Cloud Migration
  • AWS Services
  • Azure Services
  • GCP Services
  • Kubernetes
  • DevOps
  • Full Stack Development
  • Custom Software Development
  • SaaS Development
  • App Modernization
  • Mobile App Development
  • Web Development
  • UI/UX Design
  • Salesforce
  • SAP
  • ServiceNow
  • Microsoft Dynamics
  • Snowflake
  • Databricks
  • Healthcare
  • Finance
  • eCommerce
  • Logistics
  • Fintech
  • Real Estate
  • Education
  • Insurance
  • About Us
  • Leadership Team
  • Customer Reviews
  • Infrastructure
  • Our Locations
  • Partnership
  • Press Room
  • Blog
  • Insights

Technologies

Customer Stories

Contact Us

Find a Developer
book a 30 min call
Angular + Redux + RxJs = NGRX

How to build an Angular application using NgRx (Angular 8 + Redux)- Part 2

Aishwary Rawat
Aishwary Rawat Director of Engineering
Last Updated on March 10, 2025 | Written By: Aishwary Rawat

In first part of the NgRx tutorial, we have covered the core concepts and detailed descriptions about what is NgRx; it’s a workflow and its need.

In the second installment, we will learn how to use actions, reducers, selectors, and effects in our application. So you will get an idea of how actually they are interrelated to each other.

So let’s get started.

In the following example, I will display the list(get) of users and add(post) a user using NgRx concepts. Also, I am going to change the state of the loader flag when HTTP request is called.

Before getting into the code, let’s see what we will be making.

Here is the Demo

GitHub Repository

ANGULAR CLI VERSION : “@angular/cli”: “~8.3.20”

Note: Add the Redux dev tools extension in your browser to check the store and state changes.

Install @angular/cli using the following command

npm i -g @angular/cli

Let’s create a new angular application.

ng new Ngrx-demo

ngrx
ngrx

After successfully creating the application, we will be adding the dependencies for @ngrx in our app.

npm install @ngrx/{store,effects,store-devtools}

And to make our application look better, we will be using ng-bootstrap and bootstrap package. It is not necessary, as you can add your own CSS framework or custom CSS.

npm install --save @ng-bootstrap/ng-bootstrap

Also, add the bootstrap package.

npm i bootstrap 

After successfully adding it, update your angular.json styles array.

 "styles": [
             "src/styles.scss",
             "node_modules/bootstrap/dist/css/bootstrap.min.css"
           ],

Now, let’s add these modules in our root module. i.e App Module

Are you looking to develop an Angular application using NgRx? Hire Angular Developer from us to build a reliable and robust Angular application with Angular 8 + Redux.

app.module.ts

StoreModule contains the state variable that holds our current state value. Here, users are our state variables. Generally, state variables are defined in selector.ts

EffectsModule loads the effects file when any action is dispatched.

NOTE: Here, I am using the below structure. It may vary according to your project structure.

EffectsModule

NOTE: I will be adding code in respective files. Kindly replace it with yours.

Now, let’s create a store folder to manage our NgRx flow in one place.

NgRx flow

actions.ts

In an action file, we take the enum type variable and assigns our actions to it. We need to create a class for each action that implements the Action interface.

In GetUserLoad = “[User] Get User,” there is no compulsion to write the string part(i.e. “[User] Get User”) But it is good practice to mention as it will help you to see which action leads to state changes in redux devtool extension.

It is a must to export the actions that I have done in the last line.

reducer.ts

In reducer, a type of action is being checked, and then our state gets updated.

effects.ts

Here, which effect gets called will be decided based on the action that is matched in ofType.

As in getUsers$, GetUserLoad action is dispatched from the get-user component.

We can also dispatch other actions here. Like, after a successful API call, it dispatches GetUserSuccess action and passing ‘user’ payload to it. Likewise, on failure, GetUserFail action gets dispatched with an error.

selector.ts

Selector helps in fetching and manipulating the data present in our current state. So here I am creating two const, first for getting all users and another for getting the first ten users.

index.ts

After completing the store folder, we will now add components, service, and interface. Let’s go!

ng g c get-user
ng g c post-user 

After successfully creating components, let’s add some code to it.

get-user.component.html

get.user.component.ts

post-user.component.html

post-user.component.ts

Now I am going to add a service file. Use the following command.

ng g service _services/users

This will create a users.service.ts file in a folder named _services.

 users.service.ts

Note: I am using fake rest APIs from https://jsonplaceholder.typicode.com/.

You can delete the users.spec.ts file as we are not going to write any test cases here.

users.service.ts

Now let’s add the interface file. Use the command below.

ng g interface _interfaces/users

This will create a users.ts file in a folder named _interfaces.

interfaces

user.ts

Now finally calling get-user and post-user components in app.component.html using their selector.

app.component.html

In app.component.html, delete all the starter code and add this code.

Finally, our coding part is done. Let’s run the application using the serve command.

ng s --port 4300

After compiling successfully, you will see this.

ngrx demo

That’s all!

I hope you enjoyed reading the blog post. Please, let me know your thoughts in the comment section below

Thank you and Happy Coding?


Expand Your Digital Horizons With Us.

Start a new project or take an existing one to the next level. Get in touch to start small, scale-up, and go Agile.

Your Success Is Guaranteed !

Related Articles

Dhara Shah

June 4, 2026

AngularJS

Angular 22 Features: What’s New, What Breaks, and Should You Upgrade?

By : Dhara Shah

Angular released v22 on June 3, 2026. The latest Angular version announced Signal Forms, Resource APIs, and Angular Aria are...

Read More
Dipal Bhavsar

November 21, 2025

AngularJS

Angular 21: Latest Features, Updates & Advancements

By : Dipal Bhavsar

Read More
Dipal Bhavsar

November 3, 2025

AngularJS

7 Easiest Ways to Use AI in Angular

By : Dipal Bhavsar

Read More
Bacancy Technology

AI-powered enterprise software engineering since 2011.

Trusted by Fortune 500 companies.

4.6 Google Reviews 4.5 Glassdoor Reviews 4.8 Clutch Reviews 4.5 GoodFirms Reviews
ISO/IEC 27001:2022 Information Security Management System
Great Place To Work Get in Touch
Schedule Call

Looking for expert advice?

Schedule a Expert Call
Offices:
New Jersey New Jersey
Canada Toronto
India Ahmedabad
India Pune
India Bengaluru
UK London
Australia Adelaide
Sweden Gothenburg
UAE Dubai
  • About Us
  • Careers
  • Case Studies
  • Use Cases
  • Press Release
  • Blog
  • Insights
  • Contact Us
  • Customer Reviews
  • Privacy
  • Sitemap

© 2026 Bacancy Services Private Limited All Rights Reserved.

  • Facebook
  • Twitter
  • LinkedIn
  • YouTube
  • Instagram
  • Dribbble
  • Behance
  • Pinterest