We have been trying to incorporate PrimeNG components into a JHipster (angular 4) generated project with no success. After download and install PrimeNG into our project, we are able to import classes but when we include the corresponding tags into templates nothing is drawn. We have tested several of the PrimeNG components. Also we have done the imports in app.module, etc. I would like to be more concrete, but no error is displayed anywhere. Do you have any hint on how work with PrimeNG and JHipster together? Thanks
相关问题
- Ignore Typescript errors in Webpack-dev-server
- Webpack Encore: cannot import local dependencies
- Webpack getting started, import error
- DOMContentLoaded not firing after navigation but f
- How do I fix typescript compiler errors on css fil
相关文章
- 运行"WEBPACK_ENV=online webpack -p",如何将.scss e6文件转化
- Mapstruct generated class not being injected by Sp
- React and typescript with webpack typing issue
- Log to node console or debug during webpack build
- Configuring electron-webpack renderer to work with
- Disable tree shaking in Webpack 4
- webpack-dev-server: how to get error line numbers
- How to import a npm package in an angular2 compone
I just got PrimeNG working with JHipster 4.4.1 (using Angular4 and SCSS).
Julien's comment above, and Marcin's answer about
vendor.css
, combine to give you the solution. However, as a newcomer to JHipster, even after reading this thread, it took me a couple tries to put that together correctly.So, to clarify, here is what worked for me:
1. Install PrimeNG and dependencies
Run
yarn add primeng
to install PrimeNG as a dependency for your app.Run
yarn add @angular/animations
(see PrimeNG Setup Guide for an explanation of this).2. Add the PrimeNG styles to your app
Instead of using
.angular-cli.json
to add the styles to the build, simply@import
them in yourvendor.scss
(orvendor.css
). For me, that meant adding these two lines at the end ofcontent/scss/vendor.scss
:Run
yarn run webpack:build:vendor
.If, like me, your build fails because it cannot find a few image files, I got around it by simply copying the
node_modules/primeng/resources/images/
directory intocontent/scss/
. Perhaps someone has a more "correct" way to solve this, but that workaround did the trick for me.3. Make sure animations are included in your module
If they weren't already, make sure you're importing animations in any module that will use PrimeNG (I did this on my root module):
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Don't forget to also add this to the @NgModule
imports
array.4. Start using PrimeNG!
Now everything should be wired up -- just follow PrimeNG's docs to import and use their components within yours.
i.e.
import { AccordionModule } from 'primeng/primeng'
(also add to @NgModuleimports
).Update for PrimeNG 6
Follow top answers here but also need to add primeicons dependency. See my answer here for more info
yarn add primeicons
vendor.css
add@import '~primeicons/primeicons.css';
(not sure if import order matters)I didn't see this thread before sorry. It tooks me a couple of hours to integrate PrimeNG, as I'm learning Angular4.
Here a link to my personnal project, if you want to see the integration for PrimeNG: https://github.com/pascalgrimaud/qualitoast
And here, the specific PR with the diff: https://github.com/pascalgrimaud/qualitoast/pull/39/files
Hope it can help :)
The following steps worked for us.
1- Add dependecies with
yarn
2- Created new component with ng cli, standing on the same folder where you want to create the component run
This will
new-cmp
folder with the.html
and.ts
that you need.home.module.ts
3- Add the
imports
of the prime components you want to use along with theBrowserAnimationsModule
on the module where the new component was declared, in our casehome.module.ts
for example:AND add them to the imports array inside the @NgModule
4- Go to
src/main/webapp/content/scss/vendor.scss
and import the styles, like Marcin Krajewski suggests:5- Add a prime component for testing in the html of the created component, for example
<button pButton type="button" label="Click"></button>
6- Run
yarn run webpack:build
so the apps picks up the changes fromvendors.scss
7- Run
yarn start
and test it out!UPDATE Jhipster version: 4.5.2
This is a solution that worked for me with other module (
angular-calendar
) and it imports styles fromnode_modues
directoryAdd to file:
vendor.css :
and run