Get App Name And Version In Angular

How to read or display the name and version of your application in Angular without duplicating these information

Photo by Joe Chau on Unsplash

Import JSON File In TypeScript

"compilerOptions": {
"resolveJsonModule": true
},

Environment Variables

import {name, version} from '../../package.json';

export const environment = {
production: true,
name,
version
};

AngularFire Analytics

import {AngularFireAnalyticsModule, 
APP_NAME, APP_VERSION, CONFIG}
from '@angular/fire/analytics';
import {environment} from '../environments/environment';@NgModule({
providers: [
{
provide: CONFIG,
useValue: {
allow_ad_personalization_signals: false,
anonymize_ip: true
}
},
{provide: APP_NAME, useValue: environment.name},
{provide: APP_VERSION, useValue: environment.version}
]
})
export class AppModule {
}

Summary

Freelancer by day | Creator of DeckDeckGo by night | Organizer of the Ionic and IndieHackers Zürich Meetup

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store