0

There is a isDevMode convenience method is Angular, as described here: https://alligator.io/angular/environment-variables/

      import { Component, OnInit, isDevMode } from '@angular/core';

Is there a convenience method to get the actual environment mode? Like prod, dev, mock, etc?

I know I can add an extra variable in environment.ts for it. But if we are running the app with --environment mock already, I don't want to have to set environmentMode=mock in environment.mock.ts

techguy2000
  • 4,861
  • 6
  • 32
  • 48

1 Answers1

0

You cannot get ENV variables on Client which is browser. You can send request to a rest service on your server, and get environment from backend, then response back to client

app.get("/rest/getenv", function(req, res) {
    var env = process.env.ENV_VARIABLE;
    res.json({result: env});
});

EDIT

No, there is no such thing to get environment Mode.

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396