Mocked Services injecten with a global switch

12 views
Skip to first unread message

Andre van der plas

unread,
May 4, 2016, 2:46:33 AM5/4/16
to AngularJS
Hello,

We are working on our Angular 2 project and are looking for a way to swap all injections to our services with mocked versions.
We want to do this so we can detach ourselves from the backend if need be.
The backend currently changes a lot, and we want to be able to keep working even when the backend is down or whatever.
Therefore we want to be able to use mocked versions of the DTO's that we work with in our app.
These DTO's are now filled with data from the backend by calling the appropriated services.
We want to be able to use dummy DTO's with hardcoded values by just changing a global property (mock = true)

Is it possible to configure the DI container of Angular 2 in such a way that by changing a global property all injected services are replaced by mocked ones?

tnx
Reply all
Reply to author
Forward
0 new messages