totothegreat
totothegreat

Reputation: 1643

Changing toaster class from the controller toaster.pop()

Im using toaster for angular:

https://github.com/jirikavi/AngularJS-Toaster

This is my directive:

<toaster-container toaster-options="{'time-out': 3000}"></toaster-container>

all good here, what i want to do is this, right now it shows me all the msgs in right top corner of the screen, which is what i want (it's also the default behavior), i want to do (for some particular msgs) this:

<toaster-container toaster-options="{'position-class': 'toast-top-full-width'}"></toaster-container>

Now i can't seem to find any option to change the position class from the pop() method:

https://github.com/jirikavi/AngularJS-Toaster/pull/40/files?short_path=04c6e90

What i currently have is simple msgs like:

toaster.pop('success','Redirecting to paypal');

And i need something like this:

   toaster.pop('success','Redirecting to paypal',{'position-class':'toast-top-full-width'});

What should i do?

Upvotes: 1

Views: 3725

Answers (1)

pedrommuller
pedrommuller

Reputation: 16066

I usually post the toaster configuration in my index page, since I'm using toaster to send notifications across the system that's a suitable place to write it and not repeat the configuration.

<toaster-container toaster-options="{
  'closeButton': false,
  'debug': false,
  'positionClass': 'toast-top-right',
  'onclick': null,
  'showDuration': '200',
  'hideDuration': '1000',
  'timeOut': '5000',
  'extendedTimeOut': '1000',
  'showEasing': 'swing',
  'hideEasing': 'linear',
  'showMethod': 'fadeIn',
  'hideMethod': 'fadeOut'
}"></toaster-container>

don't forget to include the file AngularJS-Toaster/toaster.css to your index reference

then the signature for the pop is the following:

(type, title, body, timeout, bodyOutputType, clickHandler)

so you'll have to do something like

toaster.pop('success','Redirecting to paypal',null,'5000','toast-top-full-width');

Upvotes: 3

Related Questions