mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
54 lines
1.0 KiB
TypeScript
54 lines
1.0 KiB
TypeScript
import {
|
|
ChangeDetectionStrategy,
|
|
Component,
|
|
effect,
|
|
model,
|
|
} from '@angular/core';
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
@Component({
|
|
standalone: true,
|
|
imports: [FormsModule],
|
|
selector: 'app-root',
|
|
template: `
|
|
<section class="flex gap-5">
|
|
<p>MacBook</p>
|
|
<p>1999,99 €</p>
|
|
</section>
|
|
|
|
<section>
|
|
<p>Extras:</p>
|
|
|
|
<div>
|
|
<input type="checkbox" [(ngModel)]="drive" />
|
|
+500 GB drive-space
|
|
</div>
|
|
<div>
|
|
<input type="checkbox" [(ngModel)]="ram" />
|
|
+4 GB RAM
|
|
</div>
|
|
<div>
|
|
<input type="checkbox" [(ngModel)]="gpu" />
|
|
Better GPU
|
|
</div>
|
|
</section>
|
|
`,
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class AppComponent {
|
|
drive = model(false);
|
|
ram = model(false);
|
|
gpu = model(false);
|
|
|
|
constructor() {
|
|
/*
|
|
Explain for your junior team mate why this bug occurs ...
|
|
*/
|
|
effect(() => {
|
|
if (this.drive() || this.ram() || this.gpu()) {
|
|
alert('Price increased!');
|
|
}
|
|
});
|
|
}
|
|
}
|