Skip to content

fix(command/generate): directive selector should be camelcase #424

Closed

Description

@0x-r4bbit

Generating a directive using:

$ ng g directive my-directive

Generates a directive that looks like this:

@Directive({
  selector: 'my-directive',
  providers: [],
  host: {},

})
class MyDirective {}

There are a two things that need a fix IMO:

  1. directive selectors should be camelcase, so instead of my-directive I should get myDirective
  2. providers and host are not necessarily needed maybe we can simply remove those?
  3. If we can't remove them, then the trailing comma and newline should be at least removed

Activity

  1. Brocco commented on Apr 12, 2016

    @Brocco
    Contributor

    This will be included with the style-guide alignment PR I'm working on, so keep an eye out for that.

    When running ng g directive myDir the selector should be myDir
    However when running ng g directive my-dir should the selector be my-dir or myDir
    my suggestion would be for my-dir

    Furthermore if I run ng g directive mySiLyDiRECTiveName should the selector be mySiLyDiRECTiveName

    //CC @IgorMinar @johnpapa

  2. johnpapa commented on Apr 12, 2016

    @johnpapa
    Contributor

    good question ... not sure. mySillyDirectiveName would be ideal .... but I think it is very reasonable to make it mySiLyDiRECTiveName

  3. johnpapa commented on Apr 12, 2016

    @johnpapa
    Contributor

    I agree with all of @PascalPrecht 's points too.

  4. Brocco commented on Apr 12, 2016

    @Brocco
    Contributor

    For the initial I will implement it as what you provide as the argument will be the selector used in the directive this way the dev can explicitly decide on what the name will be.

  5. 0x-r4bbit commented on Apr 12, 2016

    @0x-r4bbit
    Author

    @Brocco tbh I haven't thought of simply doing ng g directive camelCase. This would totally do it.

  6. Brocco commented on Apr 12, 2016

    @Brocco
    Contributor

    @PascalPrecht correct, but the current version will output the dasherized name see here

  7. 0x-r4bbit commented on Apr 12, 2016

    @0x-r4bbit
    Author

    Oh then I misunderstood this. Thought this was already the case. Then I'm looking forward to this! :)

  8. Brocco commented on Apr 12, 2016

    @Brocco
    Contributor

    If you want you can play with the branch I'm working on should have the full PR ready in the next few days

    https://github.com/Brocco/angular-cli/tree/style-guide

  9. Brocco commented on Apr 19, 2016

    @Brocco
    Contributor

    This issue has been addressed via PR #427 selectors for directives will not adjust the name entered via the CLI (i.e. ng g directive FoObAr will have a selector: FoObAr)

  10. angular-automatic-lock-bot commented on Sep 5, 2019

    @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.

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

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