Open In App

Angular PrimeNG OrderList Buttons Location

Improve
Improve
Like Article
Like
Save
Share
Report

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. In this article, we will see how to use the OrderList Buttons Location in Angular PrimeNG.

An OrderList Component is used to maintain the list of items and products. The Buttons Location can be utilized to govern the order for rendering the list & by default, it is aligned to the left side. To customize the default location, the controlsPosition property can be used. The alternate position that is available is right.

Syntax:

<p-orderList [value]="value" 
             controlsPosition="left">

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:

 

Example 1: This example describes the basic usage of the OrderList Buttons Location in Angular PrimeNG, where we are using the controlsPosition property, which is set to right.

  • app.component.html

HTML




<div id="GFG">
    <h1 style="color:green">
          GeeksforGeeks
      </h1>
    <h2>OrderList Buttons Location</h2>
  
    <div style="width:50%; ">
        <p-orderList [value]="product" 
                     header="Selling the Alphabets" 
                     controlsPosition="right">
            <ng-template let-product pTemplate="item">
                <div class="product-item">
                    <div class="product-list-detail">
                        <h5 class="p-mb-2">
                            {{product.title}}
                        </h5>
                        <h6 class="p-mb-2">
                            {{product.cost}}
                        </h6>
                    </div>
                </div>
            </ng-template>
        </p-orderList>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
export class AppComponent {
    title = 'GFG';
  
    product: any[] = [
        {
            title: 'A',
            cost: '200'
        },
        {
            title: 'B',
            cost: '300'
        },
        {
            title: 'C',
            cost: '400'
        },
        {
            title: 'D',
            cost: '500'
        },
    ]
}


  • app.module.ts

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { OrderListModule } from 'primeng/orderlist';
  
@NgModule({
    imports: [BrowserModule,
        BrowserAnimationsModule,
        OrderListModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }


Output:

 

Example 2: In this example, we will use the controlsPosition property by setting its default value as left.

  • app.component.html

HTML




<div id="GFG">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>OrderList Buttons Location</h2>
  
    <div style="width:50%; ">
        <p-orderList [value]="product" 
                     header="Selling the Alphabets" 
                     controlsPosition="left">
            <ng-template let-product pTemplate="item">
                <div class="product-item">
                    <div class="product-list-detail">
                        <h5 class="p-mb-2">
                            {{product.title}}
                        </h5>
                        <h6 class="p-mb-2">
                            {{product.cost}}
                        </h6>
                    </div>
                </div>
            </ng-template>
        </p-orderList>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
export class AppComponent {
    title = 'GFG';
    product: any[] = [
        {
            title: 'A',
            cost: '200'
        },
        {
            title: 'B',
            cost: '300'
        },
        {
            title: 'C',
            cost: '400'
        },
        {
            title: 'D',
            cost: '500'
        },
    ]
}


  • app.module.ts

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { OrderListModule } from 'primeng/orderlist';
  
@NgModule({
    imports: [BrowserModule,
        BrowserAnimationsModule,
        OrderListModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }


Output:

 

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



Last Updated : 25 Nov, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads