tanks @ Sander . I create a service and inject into my component pages as
You said .
I can acces it any page , but when i update that variable the changes will
not affect while accessing it in another page.
import { Injectable } from '@angular/core';
@Injectable()
export class GlobaldataService {
public var1="haii";
}
constructor(public obj: GlobaldataService){}
this is the service that i used . In one of my component page , I update
the variable by
*this.obj.var1 =" hello";*
in another page component *alert(this.obj.var1); *But it dispalys the older
value which is *"haii" *how can update the global variable .
Thanks in advance
On Mon, Oct 30, 2017 at 3:44 PM, Sander Elias <[email protected]> wrote:
> Hi Vinu,
>
> The correct way to handle this is to create a service and inject that
> whenever you need it. But if you really want to have a global, just create
> one in the JS global scope, and use it where you need it. Typescript will
> complain, and you need to define it in each file you are going to use it,
> but it will work nevertheless.
>
> Regards
> Sander
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Angular and AngularJS discussion" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/angular/1YPf1HEaQco/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
*Vinu Prasad*
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.