Skip to content

Answer:36 #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class AppComponent implements OnInit {
this.personService.loadPersons();
}

handleKey(event: any) {
if (event.keyCode === 13) {
handleKey(event: KeyboardEvent) {
if (event.key === 'Enter') {
this.personService.addPerson(this.label);
this.label = '';
}
Expand Down
3 changes: 1 addition & 2 deletions apps/performance/36-ngfor-optimization/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApplicationConfig } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
providers: [provideAnimations()],
providers: [],
};
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';

import { CommonModule } from '@angular/common';
import { Person } from './person.model';

@Component({
selector: 'app-person-list',
imports: [CommonModule],
template: `
<div
*ngFor="let person of persons"
class="flex items-center justify-between border-b">
<h3>{{ person.name }}</h3>
<div class="flex gap-10 py-1">
<button
class="rounded-md border bg-blue-500 p-2 text-white"
(click)="update.emit(person.email)">
UPDATE
</button>
<button
class="rounded-md border bg-red-500 p-2 text-white"
(click)="delete.emit(person.email)">
DELETE
</button>
@for (person of persons; track person.email) {
<div class="flex items-center justify-between border-b">
<h3>{{ person.name }}</h3>
<div class="flex gap-10 py-1">
<button
class="rounded-md border bg-blue-500 p-2 text-white"
(click)="update.emit(person.email)">
UPDATE
</button>
<button
class="rounded-md border bg-red-500 p-2 text-white"
(click)="delete.emit(person.email)">
DELETE
</button>
</div>
</div>
</div>
}
`,
host: {
class: 'w-full flex flex-col',
Expand Down