Open In App

Angular PrimeNG PickList Properties

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. It provides a lot of templates, components, theme design, an extensive icon library, and much more. In this article, we will see the Angular PrimeNG PickList Properties.

The PickList Component is used to reorder items between different categories and lets us pick and select items. It acts as a drag-and-drop component with two tables and contents in it.



Angular PrimeNG PickList Properties:

 



Syntax:

<p-pickList 
    sourceHeader="...." 
    targetHeader="....">

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
npm install @angular/cdk --save

Project Structure: It will look like the following:

 

Steps to run the application: Run the below command to see the output

ng serve --save

Example 1: Below is the example code that illustrates the use of Angular PrimeNG Picklist properties. In this example, we will learn about sourceHeader, targetHeader, showSourceControls, and showTargetControls.




<h1 style="color: green;">
    GeeksforGeeks
</h1>
<h3>
  Angular PrimeNG Picklist Properties
</h3>
<p-pickList  
    sourceHeader="I am a Source Header"
    targetHeader="I am a target Header" 
    [showSourceControls]="false"
    [showTargetControls]="false">
</p-pickList>




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




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { PickListModule } from "primeng/picklist";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PickListModule,
        HttpClientModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}

Output:

 

Example 2: Below is another example code that illustrates the use of Angular PrimeNG Picklist properties. In this example, we will learn about sourceFilterPlaceholder, targetFilterPlaceholder, filterBy, source, target, targetStyle, sourceStyle, responsive, dragdrop.




<div style="width: 80%;">
    <h1 style="color: green;">GeeksforGeeks</h1>
    <h2>Angular PrimeNG PickList Properties</h2>
    <p-pickList
        ="sourceProducts"
        [target]="targetProducts"
        targetHeader="I am a GFG Target List"
        [dragdrop]="true"
        sourceHeader="I am a GFG Source List"
        filterBy="name,price"
        sourceFilterPlaceholder="Search by Name / Cost"
        targetFilterPlaceholder="Search by Name / Cost"
        [responsive]="true"
        style="width: 50%;"
        [targetStyle]="{'height':'300px','background-color':'yellow'}"
        [sourceStyle]="{'height':'300px','background-color':'pink'}">
        <ng-template let-product pTemplate="item">
            <div class="product-item"
                style="background-color: green; color: white;">
                <div class="product-list-detail">
                    <h5>{{product.name}}</h5>
  
                    <img [src]="product.image" width="48" />
                </div>
                <div class="product-list-action">
                    <h6>Rs  {{product.price}}</h6>
                </div>
            </div>
        </ng-template>
    </p-pickList>
</div>




import { Component } from "@angular/core";
import { Product } from "./product";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"]
})
  
export class AppComponent {
    data: Product[] = [
        {
            id: "1000",
            code: "GFG111",
            name: "JAVA",
            description: "Programming language",
            image:
            price: 6500
        },
        {
            id: "1001",
            code: "GFG555",
            name: "Angular JS",
            description: "Front End Development",
            image:
            price: 700
        },
        {
            id: "1002",
            code: "GFG777",
            name: "CSS",
            description: "Style Sheet",
            image:
            price: 2900
        },
        {
            id: "1003",
            code: "GFG999",
            name: "HTML",
            description: "HTML Development",
            image:
            price: 3100
        }
    ];
    sourceProducts: Product[] = this.data;
    targetProducts: Product[] = [];
}




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { PickListModule } from "primeng/picklist";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PickListModule,
        HttpClientModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}

Output:

 

Reference: http://primefaces.org/primeng/picklist


Article Tags :