Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1c19e0d

Browse files
cexbrayatdgp1130
authored andcommitted
feat(@schematics/angular): use signal in app component
This updates the generated `App` component to use a signal for the `title` field.
1 parent b932f69 commit 1c19e0d

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

‎packages/schematics/angular/application/files/common-files/src/app/app.html.template‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
<clipPath id="a"><path fill="#fff" d="M0 0h982v239H0z" /></clipPath>
226226
</defs>
227227
</svg>
228-
<h1>Hello, {{ title }}</h1>
228+
<h1>Hello, {{ title() }}</h1>
229229
<p>Congratulations! Your app is running. 🎉</p>
230230
</div>
231231
<div class="divider" role="separator" aria-label="Divider"></div>

‎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/tests/build/prerender/error-with-sourcemaps.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default async function () {
2020

2121
await writeMultipleFiles({
2222
'src/app/app.ts': `
23-
import { Component } from '@angular/core';
23+
import { Component, signal } from '@angular/core';
2424
import { CommonModule } from '@angular/common';
2525
import { RouterOutlet } from '@angular/router';
2626
@@ -32,7 +32,7 @@ export default async function () {
3232
styleUrls: ['./app.css']
3333
})
3434
export class App {
35-
title = 'test-ssr';
35+
protected readonly title = signal('test-ssr');
3636
3737
constructor() {
3838
console.log(window)

‎tests/legacy-cli/e2e/tests/build/server-rendering/server-routes-output-mode-server.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export default async function () {
2121
await installWorkspacePackages();
2222

2323
// Test scenario to verify that the content length, including \r\n, is accurate
24-
await replaceInFile('src/app/app.ts', "title = '", "title = 'Title\\r\\n");
24+
await replaceInFile('src/app/app.ts', "title = signal('", "title = signal('Title\\r\\n");
2525

2626
// Ensure text has been updated.
27-
assert.match(await readFile('src/app/app.ts'), /title='Title/);
27+
assert.match(await readFile('src/app/app.ts'), /title=signal\('Title/);
2828

2929
// Add routes
3030
await writeFile(

‎tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default async function () {
66
// Update the application to use a forward reference
77
await replaceInFile(
88
'src/app/app.ts',
9-
"import { Component } from '@angular/core';",
10-
"import { Component, Inject, Injectable, forwardRef } from '@angular/core';",
9+
"import { Component, signal } from '@angular/core';",
10+
"import { Component, Inject, Injectable, forwardRef, signal } from '@angular/core';",
1111
);
1212
await appendToFile('src/app/app.ts', '\n@Injectable() export class Lock { }\n');
1313
await replaceInFile(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /