Skip to content
Angular 7 demo that combines angular-in-memory-web-api with angular-material table
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

angular material + angular-in-memory-web-api

The application connects to a mocked database and displays the result in an angular-material table.


The endpoint url must correspond to the baseUrl in app.module.ts.

// data-prod.service.ts
private url = '/api/v1/products/';
// get an array of Products
return this.http.get<Product[]>(url).pipe(catchError(this.handleError));
// in-memory-db-item.service.ts
createDb() {
    const products: Product[] = [].concat(responseJson)[0].default;
    return { products };

Connect data to the angular-material table:

// mat-table-all.component.ts
import { DataProdService } from '../../services/data-prod.service';
    private dataProdService: DataProdService,

  ngOnInit() {
    this.dataSource = new DataProdSrc(this.dataProdService);
    this.dataSource.loadProducts('/* initial search */');

Angular 7 usage:

This project was generated with Angular CLI version 7.0.6. It was modified to use jest and protractor for testing.


Install ng cli.

Install yarn.

Remove file package-lock.json if it exists.

cd materialMockApiLab; Run yarn to build node_modules.

Install yarn.

Development server

cd materialMockApiLab; Run yarn start (This will run ng serve) Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Mock api

There is a mock api to support development without external endpoints. See the files of 'app.module->HttpClientInMemoryWebApiModule' and 'app/mock-service' directory. This system is enabled for non-production build.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.


Run yarn build. This will run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.


The app is configured to use Jest together with Puppeteer for both unit and e2e tests.

Running unit tests

Run yarn test to run all unit tests and e2e tests.

Running end-to-end tests

Run yarn e2e to run all unit tests and e2e tests.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

You can’t perform that action at this time.