How to display the app version in Angular?

后端 未结 10 1522
暗喜
暗喜 2020-12-02 04:55

How do I display the app version in angular application? the version should be taken from package.json file

{
  \"name\": \"angular-app\",
  \"v         


        
10条回答
  •  [愿得一人]
    2020-12-02 05:22

    Simplist solution for angular cli users.

    Add declare module '*.json'; on src/typings.d.ts

    And then on src/environments/environment.ts:

    import * as npm from '../../package.json';
    
    export const environment = {
      version: npm.version
    };
    

    Done :)

提交回复
热议问题