global variable angular

Solutions on MaxInterview for global variable angular by the best coders in the world

showing results for - "global variable angular"
Isabel
30 Jun 2017
1//Use a shared service:
2import { Injectable } from '@angular/core';
3
4@Injectable()
5export class AppService{
6    myGlobalVar;
7
8    constructor(){
9      this.myGlobalVar = true;
10      alert("My intial global variable value is: " + this.myGlobalVar);
11    }
12
13    setMyGV(val: boolean){
14      this.myGlobalVar = val;
15    }
16
17    getMyGV(val: boolean){
18      return this.myGlobalVar;
19    }
20}
21//Remember to add it to the app.module providers
similar questions
queries leading to this page
global variable angular