how to set `export default class` when generating components instead of `export class`

Discussão em 'Angular' iniciado por otaxhu, Janeiro 24, 2025.

  1. otaxhu

    otaxhu Guest

    I don't know if setting export default for my components is a bad practice, I'm new to Angular and I want to do it because I want to import the component without the curly braces

    I want the ng g c home generate this:

    import { Component } from '@angular/core';
    import { CommonModule } from '@angular/common';

    @Component({
    selector: 'app-home',
    standalone: true,
    imports: [CommonModule],
    templateUrl: './home.component.html'
    })
    export default class HomeComponent { // Note the default modifier.

    }



    So I can import it in any component without the curly braces

    import HomeComponent from "./home/home.component";

    Continue reading...

Compartilhe esta Página