How to display the app version in Angular?

后端 未结 10 1531
暗喜
暗喜 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:11

    Using the tsconfig option --resolveJsonModule you can import json files in Typescript.

    In the environment.ts file:

    import { version } from '../../package.json';
    
    export const environment = {
        VERSION: version,
    };
    

    You can now use environment.VERSION in your application.

提交回复
热议问题