Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Toastr notification for Angular templates


Hi,

Currently, I'm using an Angular based template but I noticed that Toastr is not part of the demo. Searching on the documentation, I noticed that it is implemented as part of HTML.
https://preview.keenthemes.com/html/metronic/docs/general/toastr

Do you have a workaround to use Metronic Toastr for Angular applications?

PD: This is critical for my notifications system and I would like to continue using the Metronic look and feel and avoid installing external libraries that add more weight to the application.

Thanks in advance.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Deleted comment
Deleted comment

Hi Carlos,

You can use the Metronic Toastr for Angular applications by installing the ngx-toastr package. Here are the steps:

  1. Install the ngx-toastr package using npm:
npm install ngx-toastr
  1. Import the BrowserAnimationsModule and ToastrModule in your app.module.ts file:
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';

@NgModule({
 imports: [
 BrowserAnimationsModule,
 ToastrModule.forRoot()
 ]
})
  1. In your component where you want to use Toastr, import the ToastrService and use it in your code:
import { ToastrService } from 'ngx-toastr';

@Component({
 ...
})
export class MyComponent {
 constructor(private toastr: ToastrService) {}

 showMessage() {
 this.toastr.success('Message sent successfully!');
 }
}

With this setup, you can use the Toastr service in your Angular application. By right, it will keep the Metronic look and feel for your notifications system.

Moreover, the Metronic custom Toastr style is already included in the _toastr.scss file, which can be found in the demo1/src/assets/sass/core/vendors/plugins/ directory. You can also confirm that it is imported in the _plugins.scss file located in the same directory.

Thanks

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(