Answer the question
In order to leave comments, you need to log in
How to access a variable from another component in Angular 2?
Good afternoon. There are two components:
//first.component.ts
export FirstComponent implements OnInit {
user:User;
ngOnInit(): void {
this.user = { id: 1 };
}
}
//second.component.ts
export SecondComponent {
user:User;
}
Answer the question
In order to leave comments, you need to log in
for example, use the redux architecture blog.angular-university.io/angular-2-application-a... or
- injectors (smoke the angular dock);
- services (we also smoke the dock);
- Input (we also smoke the dock);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question