I declared a custom rooting property in the ts file as shown below
module MyApp.Entity{
export interface IRootScope extends ng.IRootScopeService {
userData: any;
clientData: any;
}
}
In one of my service files, I assigned a value
export class Service1 {
constructor(private apiService: MyApp.Common.Services.apiService, private notificationService: MyApp.Common.Services.notificationService,
private $base64: JQueryBase64Static, private $cookieStore: ng.cookies.ICookieStoreService, private $rootScope: MyApp.Entity.IRootScope) {
}
saveData(){
this.$rootScope.clientData = clientData;
}
}
Now in another Controller file, I tried to access this rootcope property
class controller2{
Clients: any;
constructor(private service1: MyApp.Service.Service1, private $rootScope: MyApp.Entity.IRootScope){
this.Clients = this.$rootScope.clientData;
}
}
source
share