Open In App

Angular PrimeNG Chip Image

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use the Chips Image in Angular PrimeNG.

The Chips component sets multiple values to enter for an input field.



Syntax:

<p-chip
     label="..."
     image="..."
     [removable]="true">
</p-chip>

Angular PrimeNG Chip Image properties:



Creating Angular Application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

 

Run the below command to see the output:

ng serve --open

Example 1: Below is the example code that illustrates the use of the Angular PrimeNG Chip Image.




<h2 style="color: green">
    GeeksforGeeks
</h2>
<h5>Angular PrimeNG Chips Image</h5>
  
<div class="p-d-flex p-ai-center">
    <p-chip label="DSA for Professionals" 
        styleClass="p-mr-3"
        image=
    </p-chip>
    <p-chip label="DSA Self-Paced" 
        styleClass="p-mr-3"
        image=
    </p-chip>
    <p-chip label="System Design" 
        styleClass="p-mr-3"
        image=
    </p-chip>
    <p-chip label="C++ STL Self Paced"
        image=
    </p-chip>
</div>




import { Component } from "@angular/core";
  
@Component({
      selector: "app-root",
      templateUrl: "./app.component.html",
      styleUrls: ["./app.component.scss"]
})
  
export class AppComponent {}




import { NgModule } from "@angular/core";
import { BrowserModule }
    from "@angular/platform-browser";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
import { BadgeModule } from "primeng/badge";
import { ChipModule } from "primeng/chip";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ChipModule,
        ButtonModule,
        BadgeModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Example 2: Below is another example code that illustrates Angular PrimeNG Chip Image using the [removable]=”true” property.




<h2 style="color: green">
    GeeksforGeeks
</h2>
  
<h5>Angular PrimeNG Chips Image</h5>
  
<div class="p-d-flex p-ai-center">
    <p-chip label="DSA for Professionals" 
        styleClass="p-mr-3"
        image=
        [removable]="true">
    </p-chip>
    <p-chip label="DSA Self-Paced" 
        styleClass="p-mr-3"
        image=
        [removable]="true">
    </p-chip>
    <p-chip label="System Design" 
        styleClass="p-mr-3"
        image=
        [removable]="true">
    </p-chip>
    <p-chip label="C++ STL Self Paced"
        image=
        [removable]="true">
    </p-chip>
</div>




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.scss"]
})
  
export class AppComponent { }




import { NgModule } from "@angular/core";
import { BrowserModule }
    from "@angular/platform-browser";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
import { BadgeModule } from "primeng/badge";
import { ChipModule } from "primeng/chip";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ChipModule,
        ButtonModule,
        BadgeModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Reference: https://primefaces.org/primeng/chip


Article Tags :