Skip to content

Commit

Permalink
feat(@schematics/angular): use signal in app component
Browse files Browse the repository at this point in the history
This updates the generated `AppComponent` to use a signal for the `title` field.
  • Loading branch information
cexbrayat committed Dec 11, 2024
1 parent 210bf4e commit a932661
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('AppComponent', () => {
it(`should have as title '<%= name %>'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('<%= name %>');
expect(app.title()).toEqual('<%= name %>');
});

it('should render title', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component } from '@angular/core';
import { Component, signal } from '@angular/core';

@Component({
selector: '<%= selector %>',<% if(inlineTemplate) { %>
template: `
<h1>Welcome to {{title}}!</h1>
<h1>Welcome to {{ title() }}!</h1>

<% if (routing) {
%><router-outlet /><%
Expand All @@ -15,5 +15,5 @@ import { Component } from '@angular/core';
styleUrl: './app.component.<%= style %>'<% } %>
})
export class AppComponent {
title = '<%= name %>';
title = signal('<%= name %>');
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('AppComponent', () => {
it(`should have the '<%= name %>' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('<%= name %>');
expect(app.title()).toEqual('<%= name %>');
});

it('should render title', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component } from '@angular/core';<% if(routing) { %>
import { Component, signal } from '@angular/core';<% if(routing) { %>
import { RouterOutlet } from '@angular/router';<% } %>

@Component({
selector: '<%= selector %>',
imports: [<% if(routing) { %>RouterOutlet<% } %>],<% if(inlineTemplate) { %>
template: `
<h1>Welcome to {{title}}!</h1>
<h1>Welcome to {{ title() }}!</h1>

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

0 comments on commit a932661

Please sign in to comment.