I have two components:
Registration and Login
In the RecordComponent I have this anchor:
<a id="titleClient">Already have a account? Click here</a>
I need when the user clicks the anchor change in the login component the attribute of my class "already_client" to true:
export class LoginComponentimplements OnInit {
already_client: boolean
...
}
I thought of doing with input property but I use the router-outlet to show the components, I can not use, for example:
How can I do this?
Thank you
@Edit:
How did it work for me:
My login component:
ngOnInit() {
this.handleSubscriptions()
}
public handleSubscriptions() {
this.subscription = this.registrarService.params.subscribe(
action => {
if(action !== undefined){
this.usuario.cliente= action.action
}
}
)
}
Register component:
setPossuiConta(){
this.registrarService.setParameters(true);
this.router.navigate(['/login']);
}
Service:
private cliente: BehaviorSubject<any> = new BehaviorSubject<any>({} as any);
public params = this.cliente.asObservable().pipe(distinctUntilChanged());
public setParameters(possui_conta: boolean) {
this.cliente.next({action: possui_conta});
}