Loading…

How to declare a global variable in Angular 2?

The simplest way is to put the variables in a file and export them. In order to use global variables, you can use an import statement.

//

   // ===== This File is as globalfile.ts

// 'use strict';

export const name='bestinterviewquestion.com';

 

After that we can export this file where we want to use these global variables value.
import * as myGlobalsFile from './globalfile';

Suggest An Answer

No suggestions avaliable!

Latest post from Angular 2 Interview Questions

Ask Question