Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to access variable from another component in angular

Go to your app.module.ts and make the provider of that component 
you want to inherit with other classes:

Ex: providers: [DatePipe, AccountComponent]


Then go to the class you want access of that variable, 
and import the component into that:

Ex: import { AccountComponent } from '../account/account.component';


Make the constructor of it:

Ex:
constructor(private accountComponent: AccountComponent){}

And happily get access to the variables:
Ex: this.url = this.accountComponent.apiEndPoint+'hello';
Comment

how to access variable from another component in angular

Go to your app.module.ts and make the provider of that component 
you want to inherit with other classes:

Ex: providers: [DatePipe, AccountComponent]


Then go to the class you want access of that variable, 
and import the component into that:

Ex: import { AccountComponent } from '../account/account.component';


Make the constructor of it:

Ex:
constructor(private accountComponent: AccountComponent){}

And happily get access to the variables:
Ex: this.url = this.accountComponent.apiEndPoint+'hello';
Comment

PREVIOUS NEXT
Code Example
Javascript :: react-tweet-embed 
Javascript :: polymorphism javascript 
Javascript :: javascript regex insert string 
Javascript :: jest check if button is disabled 
Javascript :: DateRangePicker start and end date in one Textfeild material ui 
Javascript :: js to find min value in an array 
Javascript :: simple todo list javascript 
Javascript :: pdf js 
Javascript :: nested arrays reactjs tables 
Javascript :: Example React Hook 
Javascript :: nodemailer 
Javascript :: string immutable javascript 
Javascript :: set meterial icon color change onClick react 
Javascript :: js get elements in array from x to y 
Javascript :: Use the parseInt Function 
Javascript :: angular set time 
Javascript :: combine csv files javascript 
Javascript :: javascript image preview before upload 
Javascript :: boolean as string javascript 
Javascript :: javascript test cases 
Javascript :: loopback 
Javascript :: dynamic useState in react 
Javascript :: javascript weakmap 
Javascript :: try without catch 
Javascript :: longest word in a string 
Javascript :: npm font awesome angular 12 
Javascript :: laravel json eloquent 
Javascript :: leaflet js 
Javascript :: how to remove elements from array 
Javascript :: js sort array 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =