Skip to content

Commit db677fc

Browse files
committed
feat(@schematics/angular): use signal in app component
This updates the generated `App` component to use a signal for the `title` field.
1 parent 63d542c commit db677fc

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

packages/schematics/angular/application/files/module-files/src/app/app.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.<%= style %>'<% } %>
1616
})
1717
export class App {
18-
protected title = '<%= name %>';
18+
protected readonly title = signal('<%= name %>');
1919
}
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.<%= style %>'<% } %>
1717
})
1818
export class App {
19-
protected title = '<%= name %>';
19+
protected readonly title = signal('<%= name %>');
2020
}

tests/legacy-cli/e2e/assets/17.0-project/src/app/app.component.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ describe('AppComponent', () => {
1414
expect(app).toBeTruthy();
1515
});
1616

17-
it(`should have the 'seventeen-project' title`, () => {
18-
const fixture = TestBed.createComponent(AppComponent);
19-
const app = fixture.componentInstance;
20-
expect(app.title).toEqual('seventeen-project');
21-
});
22-
2317
it('should render title', () => {
2418
const fixture = TestBed.createComponent(AppComponent);
2519
fixture.detectChanges();

0 commit comments

Comments
 (0)