Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Keep state of previous page in Angular 10

im reading data in component A, route to component B and pass data as extras. Component B now has this data in its instance scope. I then pass this data to component C and do something with that data. If I now return to component B by going back a page, the data which I received from A (my state) is not present anymore.

My question: How can I keep the state of B?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can store your data in a shared service, as these are singleton classes, the data will persist until your application is destroyed.

@Injectable({
  providedIn: 'root',
})
export class MyService {
  data = '';
}
export class OneComponent implements OnInit {
  constructor(private myService: MyService){};

  ngOnInit(): void {
    this.myService.data = "I'm not going anywhere!"
  }
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!