Currently, I have established a local instance
of the service and am directly accessing data from it. I'm wondering if this approach is incorrect for a simple use case like sharing data between components. While trying to understand some fundamental ng2 concepts, I believe there may be a more suitable option available.
For example:
export class FormTwoComponent implements OnInit {
private model: WinnerModel;
constructor(private formService: FormService, private router: Router) {}
ngOnInit() {
this.model = this.formService.winnerModel;
}
onSubmit() {
this.formService.winnerModel = this.model;
this.router.navigate(['/form/3'])
}
}
Thank you