feat: create challenge 50 on issues with effect (#841)

This commit is contained in:
Laforge Thomas
2024-05-07 14:41:23 +02:00
committed by GitHub
parent 63528e4c89
commit bfe7f23105
24 changed files with 288 additions and 18 deletions

View File

@@ -0,0 +1,36 @@
import {
ChangeDetectionStrategy,
Component,
effect,
model,
} from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
standalone: true,
imports: [FormsModule],
selector: 'app-root',
template: `
Show Dialog if one checkbox is checked
<input type="checkbox" [(ngModel)]="name" />
Name
<input type="checkbox" [(ngModel)]="age" />
Age
<input type="checkbox" [(ngModel)]="address" />
Address
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
name = model(false);
age = model(false);
address = model(false);
constructor() {
effect(() => {
if (this.name() || this.age() || this.address()) {
alert('Checkbox was checked');
}
});
}
}

View File

@@ -0,0 +1,5 @@
import { ApplicationConfig } from '@angular/core';
export const appConfig: ApplicationConfig = {
providers: [],
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>angular-bug-effect-signal</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@@ -0,0 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { appConfig } from './app/app.config';
bootstrapApplication(AppComponent, appConfig).catch((err) =>
console.error(err),
);

View File

@@ -0,0 +1,5 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
/* You can add global styles to this file, and also import other style files */