Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions apps/signal/51-function-call-effect/src/app/action.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ChangeDetectionStrategy,
Component,
effect,
inject,
signal,
} from '@angular/core';
Expand All @@ -18,7 +17,8 @@ import { UserService } from './user.service';
</label>
<select
name="actions"
[(ngModel)]="action"
[ngModel]="action"
(ngModelChange)="logMessage($event)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahah, that's the better way but the goal was to use the untrack function. But that's a lot better. Need to find another use case 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. untrack is also nice. At least I learned how it is visualized in the Signal graph.

id="actions"
class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500">
<option selected>Please select an action</option>
Expand All @@ -36,9 +36,7 @@ export class ActionsComponent {

protected actions = ['Create', 'Read', 'Update', 'Delete'];

constructor() {
effect(() => {
this.userService.log(this.action() ?? 'No action selected');
});
logMessage(action: string | undefined) {
this.userService.log(action ?? 'No action selected');
}
}
Loading