{"id":333,"date":"2025-01-18T18:30:00","date_gmt":"2025-01-18T18:30:00","guid":{"rendered":"https:\/\/imcodinggenius.com\/?p=333"},"modified":"2025-01-18T18:30:00","modified_gmt":"2025-01-18T18:30:00","slug":"primeng-setup-in-angular-19","status":"publish","type":"post","link":"https:\/\/imcodinggenius.com\/?p=333","title":{"rendered":"PrimeNG setup in Angular 19"},"content":{"rendered":"<h3>1. What is PrimeNG?<\/h3>\n<p>PrimeNG is an open-source library with prebuilt and customizable UI components that speed up the development process for Angular. It comes under the free-to-use MIT license.<\/p>\n<h3>2. Find your Angular version<\/h3>\n<p>Run the command \u2018ng v\u2019 in your terminal to find the Angular version.<\/p>\n<p>\n    Fig 1: Angular version<\/p>\n<h3>3. Install PrimeNG<\/h3>\n<h4>3.1. Install PrimeNG and PrimeNG theme<\/h4>\n<p>Run the command \u2018npm install primeng @primeng\/themes\u2019 in your terminal to install PrimeNG and its themes.<\/p>\n<h4>3.2. Possible encountering installation error<\/h4>\n<p>You may face an installation error while installing the PrimeNG npm packages.<\/p>\n<p>\n    Fig 2: PrimeNG installation error<\/p>\n<h4>3.4. Solution to installation failure<\/h4>\n<p>Fix the upstream dependency conflict or retry this command with \u2013force<\/p>\n<p>Retry the same command with \u2018\u2013force\u2019,<\/p>\n<p>\u2018npm install primeng @primeng\/themes \u2013save \u2013force\u2019 to install the PrimeNG packages.<\/p>\n<h3>4. Verify your installation<\/h3>\n<p>Verify the installation of PrimeNG by checking the package.json file.<\/p>\n<p>\n    Fig 3: PrimeNG verify installation<\/p>\n<h3>5. Add reference to PrimeNG<\/h3>\n<h4>5.1. Add reference to PrimeNG (app.config.ts approach)<\/h4>\n<p>Add a reference to PrimeNG animation, ProvidePrimeNG, and the theme (\u2018Aura\u2019) in your app.config.ts to use the PrimeNG UI components across your Angular project. You may not have needed to manually add the CSS references in the angular.json or global styles.css file because it will be taken care of by the PrimeNG themes package in the newer PrimeNG version 19.<\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">app.config.ts,\n<p>import { ApplicationConfig } from &#8216;@angular\/core&#8217;;<br \/>\nimport { provideAnimationsAsync } from &#8216;@angular\/platform-browser\/animations\/async&#8217;;<br \/>\nimport { providePrimeNG } from &#8216;primeng\/config&#8217;;<br \/>\nimport Aura from &#8216;@primeng\/themes\/aura&#8217;;<\/p>\n<p>export const appConfig: ApplicationConfig = {<br \/>\n    providers: [<br \/>\n        provideAnimationsAsync(),<br \/>\n        providePrimeNG({<br \/>\n            theme: {<br \/>\n                preset: Aura<br \/>\n            }<br \/>\n        })<br \/>\n    ]<br \/>\n};<\/p>\n<p>ButtonDemo.Component.ts,<\/p>\n<p>import { Component } from &#8216;@angular\/core&#8217;;<br \/>\nimport { ButtonModule } from &#8216;primeng\/button&#8217;;<\/p>\n<p>@Component({<br \/>\n    selector: &#8216;button-demo&#8217;,<br \/>\n    templateUrl: &#8216;.\/button-demo.html&#8217;,<br \/>\n    standalone: true,<br \/>\n    imports: [ButtonModule]<br \/>\n})<br \/>\nexport class ButtonDemo {}<\/p>\n<p>ButtonDemo.Component.html<br \/>\n&lt;div class=&#187;card flex justify-center&#187;&gt;<br \/>\n    &lt;p-button label=&#187;Check&#187; \/&gt;<br \/>\n&lt;\/div&gt;\n<\/p><\/div>\n<\/div>\n<h4>5.2 Add reference to PrimeNG (app.module.ts approach)<\/h4>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">app.module.ts,\n<p>import { provideAnimationsAsync } from &#8216;@angular\/platform-browser\/animations\/async&#8217;;<br \/>\nimport { providePrimeNG } from &#8216;primeng\/config&#8217;;<br \/>\nimport Aura from &#8216;@primeng\/themes\/aura&#8217;;<\/p>\n<p>import { ButtonModule } from &#8216;primeng\/button&#8217;;<\/p>\n<p>@NgModule({<br \/>\n  declarations: [<br \/>\n    AppComponent<br \/>\n  ],<br \/>\n  imports: [<br \/>\n    BrowserModule,<br \/>\n    AppRoutingModule,<br \/>\n    FormsModule,<br \/>\n    HttpClientModule,<br \/>\n    ButtonModule<br \/>\n  ],<br \/>\n  providers: [provideAnimationsAsync(),<br \/>\n    providePrimeNG({<br \/>\n        theme: {<br \/>\n            preset: Aura<br \/>\n        }<br \/>\n    })],<br \/>\n  bootstrap: [AppComponent]<br \/>\n})<br \/>\nexport class AppModule { }<\/p>\n<p>ButtonDemo.Component.html<br \/>\n&lt;div class=&#187;card flex justify-center&#187;&gt;<br \/>\n    &lt;p-button label=&#187;Check&#187; \/&gt;<br \/>\n&lt;\/div&gt;<\/p>\n<\/div>\n<\/div>\n<h4>5.3 Output (Button)<\/h4>\n<div><\/div>\n<p>\n  Fig 4: Output (Button)<\/p>","protected":false},"excerpt":{"rendered":"<p>1. What is PrimeNG? PrimeNG is an open-source library with prebuilt and customizable UI components that speed up the development process for Angular. It comes under the free-to-use MIT license. 2. Find your Angular version Run the command \u2018ng v\u2019 in your terminal to find the Angular version. Fig 1: &#8230; <\/p>\n<div><a class=\"more-link bs-book_btn\" href=\"https:\/\/imcodinggenius.com\/?p=333\">Read More<\/a><\/div>\n","protected":false},"author":0,"featured_media":334,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-333","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"_links":{"self":[{"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=\/wp\/v2\/posts\/333"}],"collection":[{"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":0,"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=\/wp\/v2\/media\/334"}],"wp:attachment":[{"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imcodinggenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}