#13: π§ Refactor App Component
We're going to perform a small refactoring. The app-root shouldn't have such a large template and all this logic. It should just call another component that will deal with that.
Create a new component called
list-manager:
ng g c list-managerMove all the code from
app-roottolist-manager.You can keep the title in app-root, and give it a nice value.
Be careful not to change the list manager component's class name!
@Component({
selector: 'app-root',
standalone: true,
imports: [CommonModule],
template: `
<h1>
Welcome to {{ title }}!
</h1>
`,
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'My To-Do List App';
}Call the new component from the
app-roottemplate:
That's it! Now we can go on.
Last updated