Skip to content

Commit c6c054a

Browse files
committed
chore(ngxs-demo): fixed "user.json" loading and clearing of todo input
1 parent 95eb01d commit c6c054a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

apps/ngxs-demo/src/todo/todo.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ <h3>TodoState</h3>
1717
<input
1818
#text
1919
placeholder="New Todo"
20-
(keydown.enter)="todo.addTodo(text.value)"
20+
(keydown.enter)="todo.addTodo(text.value); text.value = ''"
2121
/>
2222
<button
2323
type="button"
24-
(click)="todo.addTodo(text.value)"
24+
(click)="todo.addTodo(text.value); text.value = ''"
2525
>
2626
Add
2727
</button>

apps/ngxs-demo/src/user/user.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export class UserService {
1414
private readonly SIMULATE_REQUEST_DELAY: number = 2000;
1515

1616
public loadUser(): Observable<UserModel> {
17-
return this.httpService.get<{data: UserModel}>('/assets/user.json').pipe(
17+
const path = location.pathname;
18+
19+
return this.httpService.get<{data: UserModel}>(`${path}assets/user.json`).pipe(
1820
delay(this.SIMULATE_REQUEST_DELAY),
1921
map((response: {data: UserModel}): UserModel => response.data),
2022
);

0 commit comments

Comments
 (0)