我必须获取当前用户ID才能在我的应用程序的不同部分使用它.
login.component.ts:
onSignin(form: NgForm){
const UserName = form.value.UserName;
const Password = form.value.Password;
this.authService.signinUser(UserName,Password).map(res => res.json())
.subscribe(
data => {
if (data.Id == 0){
this.invalid=true;
}
else{
localStorage.setItem('isLoggedin', 'true');
this.router.navigate(['/calendar']);
console.log('Ok');
}})}
auth.service.ts:
signinUser(UserName,Password): Observable{
return this.http.get('http://api.##.com/api/security/signin?username='+UserName+'&password='+Password);
}