global variable angular
//Use a shared service:
import { Injectable } from '@angular/core';
@Injectable()
export class AppService{
myGlobalVar;
constructor(){
this.myGlobalVar = true;
alert("My intial global variable value is: " + this.myGlobalVar);
}
setMyGV(val: boolean){
this.myGlobalVar = val;
}
getMyGV(val: boolean){
return this.myGlobalVar;
}
}
//Remember to add it to the app.module providers