Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0x-r4bbit opened this issue Apr 12, 2016 · 10 comments
Closed

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

0x-r4bbit opened this issue Apr 12, 2016 · 10 comments

Comments

@0x-r4bbit
Copy link

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
@Brocco
Copy link
Contributor

Brocco commented Apr 12, 2016

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

@johnpapa
Copy link
Contributor

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

@johnpapa
Copy link
Contributor

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

@Brocco
Copy link
Contributor

Brocco commented Apr 12, 2016

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.

@0x-r4bbit
Copy link
Author

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

@Brocco
Copy link
Contributor

Brocco commented Apr 12, 2016

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

@0x-r4bbit
Copy link
Author

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

@Brocco
Copy link
Contributor

Brocco commented Apr 12, 2016

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

@Brocco
Copy link
Contributor

Brocco commented Apr 19, 2016

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)

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants