Rolando
Rolando

Reputation: 62714

How to create new component/directive in jhipster?

How do you properly add new directives/components in a jhipster project? I see that you can run commands to generate entities and services, but no directives.... what is the proper way to do this?

yo jhipster:service bar
yo jhipster:entity <entityName> 

I don't see anything for yo jhipster:directive or yo jhipster:component. How do I create a directive/component?

Upvotes: 1

Views: 3006

Answers (2)

Alan C. S.
Alan C. S.

Reputation: 15596

Just to provide more specifics, with JHipster 4 and angular 2 you can use the regular angular-cli as follows to create a directive:

  1. Open a terminal and change directory to where you want to create the directive e.g.

cd /App/src/main/webapp/app/home

  1. To create the directive type:

ng g directive <NAME-OF-YOUR-DIRECTIVE>

This will create two files: *.directive.ts and *.directive.spec.ts

It may also modify the module file (or you may have to modify it manually e.g. you may have to modify home.module.ts to add references to the newly created directive).

Upvotes: 0

Ga&#235;l Marziou
Ga&#235;l Marziou

Reputation: 16294

No there is no sub generator for directive or component assuming you're talking about JHipster 3 and angular 1.x. The entity sub generator generates both server and client code, there's no sub generator for client code only.

With JHipster 4 and angular 2, you will be able to use angular-cli for this kind of small operations on client code.

Upvotes: 1

Related Questions