2
I have two components:
Registration and Login
In the Registry I have this anchor:
<a id="titleClient">Already have a account? Click here</a>
I need when the user clicks on the anchor to change the attribute of my class "already_client" to true:
export class LoginComponentimplements OnInit {
already_client: boolean
...
}
I thought to do with input Property but I use the router-outlet to show the components, I can not use, for example:
How can I do?
Thank you
@Edit:
How it worked 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:
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});
}
You must pass the value to the login component using the Developer @Input, Please provide more details your question
– Marconi
Take a look at my answer https://answall.com/questions/305588/sharedata
– Eduardo Vargas