1
authentication.service.ts引数
import {Injectable} from '@angular/core';
import {Router} from '@angular/router';
export class User {
constructor(
public email: string,
public password: string
) { }
}
var users = [
new User('[email protected]','adm9'),
new User('[email protected]','a23')
];
@Injectable()
export class AuthenticationService {
constructor(
private _router: Router){}
logout() {
localStorage.removeItem("user");
this._router.navigate(['Login']);
}
login(user){
var authenticatedUser = users.find(u => u.email === user.email);
if (authenticatedUser){
localStorage.setItem("user", authenticatedUser);
this._router.navigate(['Home']);
return true;
}
return false;
}
checkCredentials(){
if (localStorage.getItem("user") === null){
this._router.navigate(['Login']);
}
}
}
エラー
[アット・ローダー]のsrc \アプリ\認証\認証.service.ts:32:36 'User'タイプの引数は 'string'タイプのパラメータに割り当てられません。
一応正しいです。なぜ私はそれに焦点を当てることができなかった – Pravin
@プラビンは私たちの最高を起こす:-) – echonax
答えをマークするために何分をお待ちください – Pravin