0
각도 형 CLI를 사용하고 있습니다. 사실, 난 등록 구성 요소가 있습니다 TS일부 클래스 개체를 로컬 저장소로 설정합니다.
...
export class User {
first_name: string;
second_name: string;
email: string;
password: string;
}
...
export class RegistrationComponent implements OnInit {
saveValue(storageValue) {
localStorage.setItem(`user`, new User(storageValue.first_name, storageValue.second_name));
내가 로컬 저장소에 사용자 개체를 설정하기 위해 노력하고있어 그래서
<input type="text" name="first_name" [(ngModel)]="first_name">
<input type="text" name="second_name" [(ngModel)]="second_name">
HTML하지만 오류가 있습니다 : 제공된 매개 변수가있는 서명과 일치하지 않습니다 통화 대상의 아직 tryed있다 :
...
saveValue(storageValue) {
localStorage.setItem(`user`, new User(String(storageValue.first_name), String(storageValue.second_name));
...
및
...
saveValue(storageValue) {
localStorage.setItem(`user`, JSON.stringify(new User(storageValue.first_name, storageValue.second_name));
..
그러나, 그것은 작동하지 않습니다. 누구든지 제발 도와 주실 수 있습니까?