Angular PrimeNG Messages Severities
Last Updated :
23 Aug, 2022
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 Messages Severities in Angular PrimeNG. We will also learn about the properties with their syntaxes that will be used in the code.
The Messages component is used to display a message with particular severity. Message severities are used to give different colorful message options. The possible values of severities are success, info, warn, and error.
Syntax:
<p-messages
[(value)]="..."
[enableService]="false">
</p-messages>
Angular PrimeNG Messages Severities properties:
- value: It is an array of messages to display. It is of array data type, the default value is null.
- enableService: It specifies whether displaying service messages is enabled. It is of the boolean data type, the default value is true.
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 Angular PrimeNG Messages Severities.
app.component.html
<div style="text-align: center">
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Message Severities</h5>
<p-messages
[(value)]="gfg"
[enableService]="false">
</p-messages>
</div>
app.component.ts
import { Component } from "@angular/core";
import { Message } from "primeng/api";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent {
gfg: Message[];
ngOnInit() {
this.gfg = [
{
severity: "success",
summary: "Geek-Success",
detail: "This is a success Geek",
},
{
severity: "info",
summary: "Geek-Info",
detail: "This is a info Geek",
},
];
}
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {MessagesModule} from 'primeng/messages';
@NgModule({
imports: [
BrowserAnimationsModule,
MessagesModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule{}
Output:
Example 2: Below is another example that illustrates the Angular PrimeNG Messages Severities.
app.component.html
<div style="text-align: center">
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Message Severities</h5>
<p-messages
[(value)]="gfg"
[enableService]="false">
</p-messages>
</div>
app.component.ts
import { Component } from "@angular/core";
import { Message } from "primeng/api";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent {
gfg: Message[];
ngOnInit() {
this.gfg = [
{
severity: "warn",
summary: "Geek-Warning",
detail: "This is a warning Geek",
},
{
severity: "error",
summary: "Geek-Error",
detail: "This is a error Geek",
},
];
}
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {MessagesModule} from 'primeng/messages';
@NgModule({
imports: [
BrowserAnimationsModule,
MessagesModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule{}
Output:
Reference: https://primefaces.org/primeng/messages
Similar Reads
Angular PrimeNG Messages Severities 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 Messages Severities in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Messages Dynamic 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 Messages Dynamic in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Message Service 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 Messages Service in Angular PrimeNG. We will also learn abo
3 min read
Angular PrimeNG Messages Static Content 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 the static content in Messages Component in Angular PrimeNG. The Messa
3 min read
Angular PrimeNG Messages Inline Message 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 Messages Inline Message in Angular PrimeNG. We will also
3 min read
Angular PrimeNG Messages Array 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 the Messages Array in Angular PrimeNG. The Messages component is used t
3 min read
Angular PrimeNG Messages Closable 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 Messages Closable in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Message Component 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 learn how to use the Message Component in Angular PrimeNG. We will also lea
3 min read
Angular PrimeNG Messages Animation Configuration 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.
4 min read
Angular PrimeNG Properties of Messages Component 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 learn how to use the Messages Properties in Angular PrimeNG. We will also l
4 min read