For the login feature, I am looking to receive an email using two-way databinding.
...
export class LoginComponent implements OnInit {
author ={
email:'',
password:''
}
constructor(private _auth: AuthService, private router: Router) { }
ngOnInit(): void {
}
token : any;
login(){
let sendEmail = this.author.email
this._auth.setemail(sendEmail);
console.log(sendEmail);
In the service, I am not getting any output when I try to log the data in getemail.
...
@Injectable({
providedIn: 'root'
})
export class AuthService {
serEmail= ''
setemail(data: string) {
this.serEmail= data;
console.log(this.serEmail);
}
getemail() {
let data = this.serEmail
console.log(data);
return data;
}
...
Additionally, in the header component, I aim to retrieve this data.
...
export class HeaderComponent implements OnInit {
data2: any
id: any
recEmail:any;
constructor(public _auth: AuthService) { }
ngOnInit(): void {
this.recEmail = this._auth.getemail();
console.log(this.recEmail);
...
I need assistance in transferring the data from the login component to the header component.