How to inject different service based on certain build environment in Angular2?
<p>I have <code>HeroMockService</code> that will return mocked data and <code>HeroService</code> that will call back end service to retrieve heroes from database.</p>

<p>Assuming Angular2 has build environment, I'm planning to inject <code>HeroMockService</code> to <code>AppComponent</code> if current build environment is <code>"dev-mock"</code>.  If current build environment is <code>"dev-rest"</code>, <code>HeroService</code> should be injected to <code>AppComponent</code> instead.</p>

<p>I would like to know how can I achieve this?</p>