You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng g directive generate wrong import in a module #2762
Found the difference is that the component blueprint has the option flat default set to false and the directive blueprint has it set by default to true. When I use ng g directive modulename/directivename --flat=false problem 1 is fixed, but problem 2 still exists.
~/dev/mlb/bar (master): ng g module modulename
installing module
create src/app/modulename/modulename.module.ts
installing component
create src/app/modulename/modulename.component.css
create src/app/modulename/modulename.component.html
create src/app/modulename/modulename.component.spec.ts
create src/app/modulename/modulename.component.ts
~/dev/mlb/bar (master): ng g directive directivename
installing directive
create src/app/directivename.directive.spec.ts
create src/app/directivename.directive.ts
modulename is created in it's own directory... as expected
directivename is created in the app directory... as expected
and directivename is imported and declared in app.module.ts... as expected (shown here)
You are not creating it in a module, as I'v shown in the reproduction. As I'v said: generates wrong import path, resolving relative to src/app and not src/app/module
and ng g directive generate wrong import |in a module|
Since you'v created it in src/app, it obviously works. I assume it is intended to work inside of modules, because the ng g component works, why should directives not?
Activity
akomm commentedon Oct 18, 2016
Found the difference is that the component blueprint has the option
flatdefault set tofalseand the directive blueprint has it set by default totrue. When I useng g directive modulename/directivename --flat=falseproblem 1 is fixed, but problem 2 still exists.filipesilva commentedon Oct 23, 2016
@Brocco can you have a look?
akomm commentedon Oct 24, 2016
If you want to know whether it was fixed in beta.18: No. Tested it :)
Brocco commentedon Oct 25, 2016
This seems to be behaving as expected...
modulename is created in it's own directory... as expected
directivename is created in the app directory... as expected
and directivename is imported and declared in app.module.ts... as expected (shown here)
akomm commentedon Oct 25, 2016
You are not creating it in a module, as I'v shown in the reproduction. As I'v said:
generates wrong import path, resolving relative to src/app and not src/app/moduleand
ng g directive generate wrong import |in a module|Since you'v created it in src/app, it obviously works. I assume it is intended to work inside of modules, because the
ng g componentworks, why should directives not?Brocco commentedon Oct 25, 2016
I followed your repro steps...
should they be?
With those repro steps I was able to reproduce this issue (I updated your repro steps above)
FYI, this is also an issue with pipe generations.
bug(generate): fix import path for directives & pipes when importing …
bug(generate): fix import path for directives & pipes when importing …
angular-automatic-lock-bot commentedon Sep 6, 2019
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.
bug(generate): fix import path for directives & pipes when importing …