I Have two components (RegisterComponent and Subscription) , the first component(RegisterComponent )contains a reactive form with three values (firstname, lastname, email) and the button register. I want to click register button and redirect to subscription and display firstName, lastname and email of the user. registercomponent.html
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label class="float-left">firstName</label>
<input type="text" formControlName="firstName" class="form-control" />
</div>
<div class="form-group">
<label class="float-left">lastName</label>
<input type="text" formControlName="lastName" class="form-control" />
</div>
<div class="form-group">
<label class="float-left">email</label>
<input type="text" formControlName="email" class="form-control" />
</div>
</form>
registercomponent.ts
registerForm: FormGroup;
constructor(private formBuilder: FormBuilder,private router: Router) {
}
ngOnInit(): void {
this.registerForm = this.formBuilder.group({
firstName: [''],
lastName: [''],
email: ['']
});
onSubmit() {
this.router.navigate(['/Subscription']);
}
subscriptioncomponent.html
<div>
Here i want to display the firstname,lastname and email of user
</div>
app-routing.module.ts
{ path: "register", component: RegisterComponent },
{ path: "subscription", component:SubscriptionComponent}
How can i pass the form value to my subscriptioncomponent when i click button and to display it.