Skip to content

Commit a932661

Browse files
committed
feat(@schematics/angular): use signal in app component
This updates the generated `AppComponent` to use a signal for the `title` field.
1 parent 210bf4e commit a932661

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/schematics/angular/application/files/module-files/src/app/app.component.spec.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('AppComponent', () => {
2525
it(`should have as title '<%= name %>'`, () => {
2626
const fixture = TestBed.createComponent(AppComponent);
2727
const app = fixture.componentInstance;
28-
expect(app.title).toEqual('<%= name %>');
28+
expect(app.title()).toEqual('<%= name %>');
2929
});
3030

3131
it('should render title', () => {

packages/schematics/angular/application/files/module-files/src/app/app.component.ts.template

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

33
@Component({
44
selector: '<%= selector %>',<% if(inlineTemplate) { %>
55
template: `
6-
<h1>Welcome to {{title}}!</h1>
6+
<h1>Welcome to {{ title() }}!</h1>
77

88
<% if (routing) {
99
%><router-outlet /><%
@@ -15,5 +15,5 @@ import { Component } from '@angular/core';
1515
styleUrl: './app.component.<%= style %>'<% } %>
1616
})
1717
export class AppComponent {
18-
title = '<%= name %>';
18+
title = signal('<%= name %>');
1919
}

packages/schematics/angular/application/files/standalone-files/src/app/app.component.spec.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('AppComponent', () => {
1919
it(`should have the '<%= name %>' title`, () => {
2020
const fixture = TestBed.createComponent(AppComponent);
2121
const app = fixture.componentInstance;
22-
expect(app.title).toEqual('<%= name %>');
22+
expect(app.title()).toEqual('<%= name %>');
2323
});
2424

2525
it('should render title', () => {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Component } from '@angular/core';<% if(routing) { %>
1+
import { Component, signal } from '@angular/core';<% if(routing) { %>
22
import { RouterOutlet } from '@angular/router';<% } %>
33

44
@Component({
55
selector: '<%= selector %>',
66
imports: [<% if(routing) { %>RouterOutlet<% } %>],<% if(inlineTemplate) { %>
77
template: `
8-
<h1>Welcome to {{title}}!</h1>
8+
<h1>Welcome to {{ title() }}!</h1>
99

1010
<% if (routing) {
1111
%><router-outlet /><%
@@ -16,5 +16,5 @@ import { RouterOutlet } from '@angular/router';<% } %>
1616
styleUrl: './app.component.<%= style %>'<% } %>
1717
})
1818
export class AppComponent {
19-
title = '<%= name %>';
19+
title = signal('<%= name %>');
2020
}

0 commit comments

Comments
 (0)