Skip to content

OnInit is not added to new components any more #48575

Closed

Description

@ulfrenman

Describe the problem that you experienced

The linked stackoverflow topic do explain the issue well!

ng generate component does not create ngOnInit and constructor

Enter the URL of the topic with the problem

https://stackoverflow.com/q/74870515/42580

Describe what you were looking for in the documentation

I was trying to run the TourOfHeros-tutorial when I could not match my experiance with the tutorial, so after some google-work I found the SO-topic.

Describe the actions that led you to experience the problem

No response

Describe what you want to experience that would fix the problem

No response

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here

No response

If the problem is browser-specific, please specify the device, OS, browser, and version

No response

Provide any additional information here in as much as detail as you can

No response

Activity

  1. JeanMeche commented on Dec 22, 2022

    @JeanMeche
    Member

    Thank you for reporting that, I've open a PR to update the tutorial.

  2. modified the milestone: needsTriage on Dec 23, 2022
  3. athirakarakkodath commented on Dec 24, 2022

    @athirakarakkodath

    when I create components using ng g c component name , in my ts file ngOnInit and constructor are not creating.. I have to type that manually..using latest angular version..please help me i am new to this angualr

  4. JelleBruisten commented on Dec 24, 2022

    @JelleBruisten
    Contributor

    @athirakarakkodath Since the latest angular, this has been removed from the generate component schematic. So you will need to add lifecycle interfaces yourself. ( And also don't need to remove them incase they are not needed )

  5. added a commit that references this issue on Jan 5, 2023
    8810895
  6. added 2 commits that reference this issue on Jan 5, 2023
    4bca3fe
    b3d0a27
  7. added a commit that references this issue on Feb 1, 2023
    d959d1a
  8. angular-automatic-lock-bot commented on Feb 5, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions