Skip to content

Commit 210cbd0

Browse files
committed
chore: update examples to signals
1 parent 6dab48c commit 210cbd0

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

angular-zoneless/src/app/button/button.component.cy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import { ButtonComponent } from './button.component';
33

44
@Component({
55
template: ` <app-button> Click Me </app-button> `,
6-
standalone: false,
6+
imports: [ButtonComponent],
77
})
88
class WrapperComponent {}
99

1010
describe('ButtonComponent', () => {
1111
it('can mount using WrapperComponent', () => {
12-
cy.mount(WrapperComponent, {
13-
imports: [ButtonComponent],
14-
});
12+
cy.mount(WrapperComponent);
1513
cy.get('button').contains('Click Me');
1614
});
1715

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
1+
import { Component, output } from '@angular/core';
22

33
@Component({
44
selector: 'app-button',
55
templateUrl: './button.component.html',
66
})
77
export class ButtonComponent {
8-
@Output() onClick = new EventEmitter()
8+
onClick = output<void>()
99
}

angular-zoneless/src/app/login-form/login-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<span *ngIf="submitted && !password" class="text-red-500 mt-2">Password is required</span>
1414
</label>
1515
<app-button type="submit">Login</app-button>
16-
<div *ngIf="errorMessage" class="text-red-500 mt-2">{{ errorMessage }}</div>
16+
<div *ngIf="errorMessage()" class="text-red-500 mt-2">{{ errorMessage() }}</div>
1717
</fieldset>
1818
</form>
1919
</div>

angular-zoneless/src/app/login-form/login-form.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { CommonModule } from '@angular/common';
2-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
3-
import { FormControl, FormGroup, FormsModule } from '@angular/forms';
2+
import { Component, input, output } from '@angular/core';
3+
import { FormsModule } from '@angular/forms';
44
import { ButtonComponent } from '../button/button.component';
5-
import { LoginService } from '../login.service';
65

76
@Component({
87
imports: [FormsModule, ButtonComponent, CommonModule],
98
selector: 'app-login-form',
109
templateUrl: './login-form.component.html',
1110
})
1211
export class LoginFormComponent {
13-
@Input() errorMessage = ''
14-
@Output() onLogin: EventEmitter<{ username: string, password: string }> = new EventEmitter()
12+
errorMessage = input<string>('')
13+
onLogin = output<{ username: string, password: string }>()
1514
username = ''
1615
password = ''
1716
submitted = false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="max-w-screen-sm p-12 mx-auto bg-gray-50 rounded-md shadow-lg">
2-
<h1 class="test-2xl">Welcome {{ username }}</h1>
2+
<h1 class="test-2xl">Welcome {{ username() }}</h1>
33
<app-button (onClick)="onLogout.emit()">Log Out</app-button>
44
</div>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
1+
import { Component, input, output } from '@angular/core';
22
import { ButtonComponent } from '../button/button.component';
33

44
@Component({
@@ -7,6 +7,6 @@ import { ButtonComponent } from '../button/button.component';
77
templateUrl: './welcome.component.html',
88
})
99
export class WelcomeComponent {
10-
@Input() username = '';
11-
@Output() onLogout = new EventEmitter();
10+
username = input<string>('')
11+
onLogout = output<void>()
1212
}

0 commit comments

Comments
 (0)