Skip to content

Commit

Permalink
Remember notification email address using local storage
Browse files Browse the repository at this point in the history
Fixes #9

Add functionality to remember notification email address using local storage.

* Add `noticeEmail` property in `NoticeRegisterComponent` to store the email address.
* Update `ngOnInit` method to retrieve the email address from local storage and set it as the default value in the form.
* Update `register` method to store the email address in local storage after successful registration.
* Add `[(ngModel)]` binding to the `noticeEmail` input field in the template.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Ktraveller285/jr-trainformation/issues/9?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
mugifly committed Oct 2, 2024
1 parent 642309d commit 22e9504
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/notice-register/notice-register.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
matInput
placeholder="[email protected]"
required
[(ngModel)]="noticeEmail"
#noticeEmail
/>
</mat-form-field>
Expand Down
3 changes: 3 additions & 0 deletions src/app/notice-register/notice-register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TrainService } from '../train.service';
})
export class NoticeRegisterComponent implements OnInit {
public lineName!: string | null;
public noticeEmail: string = '';

constructor(
public trainService: TrainService,
Expand Down Expand Up @@ -43,6 +44,7 @@ export class NoticeRegisterComponent implements OnInit {
cancelDecisionTime,
noticeEmail
);
window.localStorage.setItem('noticeEmail', noticeEmail);
} catch (e: any) {
// メッセージ表示
this.snackbar.open(
Expand All @@ -63,5 +65,6 @@ export class NoticeRegisterComponent implements OnInit {

ngOnInit(): void {
this.lineName = this.activatedRoute.snapshot.queryParamMap.get('line');
this.noticeEmail = window.localStorage.getItem('noticeEmail') || '';
}
}

0 comments on commit 22e9504

Please sign in to comment.