Skip to content

Commit

Permalink
refactor: Migrate to signal-based input/output, use self-closing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevanMahesha committed Feb 7, 2025
1 parent 3022998 commit e92b641
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions apps/analog-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { TopBarComponent } from '@analogjs/top-bar';
imports: [TopBarComponent, RouterOutlet],
template: `
<analogjs-top-bar />
<div class="container">
<router-outlet></router-outlet>
<router-outlet />
</div>
`,
})
Expand Down
3 changes: 1 addition & 2 deletions apps/analog-app/src/app/pages/(home).page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const routeMeta: RouteMeta = {
<p>Description: {{ product.description }}</p>
}
<button type="button" (click)="share()">Share</button>
<app-product-alerts [product]="product" (notify)="onNotify()">
</app-product-alerts>
<app-product-alerts [product]="product" (notify)="onNotify()" />
</div>
}
`,
Expand Down
1 change: 0 additions & 1 deletion apps/analog-app/src/app/pages/client/(client).page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { ServerOnly } from '@analogjs/router';

@Component({
standalone: true,
imports: [ServerOnly],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
Expand Down
1 change: 0 additions & 1 deletion apps/analog-app/src/app/pages/products.[productId].page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Product } from '../products';

@Component({
selector: 'app-product-details',
standalone: true,
imports: [CurrencyPipe],
template: `
<h2>Product Details</h2>
Expand Down
5 changes: 1 addition & 4 deletions apps/analog-app/src/app/pages/shipping/index.page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { AsyncPipe, CurrencyPipe } from '@angular/common';
import { Component, inject } from '@angular/core';

import { Observable } from 'rxjs';
import { CartService } from '../../cart.service';

@Component({
selector: 'app-shipping',
standalone: true,
imports: [CurrencyPipe, AsyncPipe],
template: `
<h3>Shipping Prices</h3>
Expand All @@ -26,6 +24,5 @@ import { CartService } from '../../cart.service';
export default class ShippingComponent {
private readonly cartService = inject(CartService);

shippingCosts: Observable<{ type: string; price: number }[]> =
this.cartService.getShippingPrices();
shippingCosts = this.cartService.getShippingPrices();
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, input, output } from '@angular/core';
import { Product } from '../products';

@Component({
selector: 'app-product-alerts',
template: `
<p>
@if ( product && product.price > 700 ) {
@if ( product() && product()!.price > 700 ) {
<button type="button" (click)="notify.emit()">Notify Me</button>
}
</p>
`,
})
export class ProductAlertsComponent {
@Input() product: Product | undefined;
@Output() notify = new EventEmitter();
readonly product = input.required<Product>();
notify = output();
}

0 comments on commit e92b641

Please sign in to comment.