Skip to content

Default standalone flag value should be TRUE #52978

@lucascouto

Description

@lucascouto

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

In angular v17, a new created project is standalone as default, what is great. Every new component created is automatically standalone. But, we still see 'standalone: true' flag in the @component metada, because its default value is false. So, what if the default value for this flag were TRUE and if the user wanted to create an ngModule component for some reason, he put 'standalone: false' in the metada?

Proposed solution

A standalone component should look like this:

@Component({
  selector: 'app-root',
  imports: [CommonModule, RouterOutlet],
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})

An ngModule component should look like this:

@Component({
  selector: 'app-root',
  standalone: false,
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})

Even though the standalone component boilerplate code is auto generated, is less code to see and it's easier to explain for new developers that is starting with Angular. And also, it makes more sense with the v17 purpose of creating standalone project as default with ng new.

Alternatives considered

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions