angular-toastr icon indicating copy to clipboard operation
angular-toastr copied to clipboard

Target for toasts doesn't exist

Open vinothmoorthkumar opened this issue 9 years ago • 6 comments

Target for toasts doesn't exist. Why This error is coming...

vinothmoorthkumar avatar Jun 30 '16 09:06 vinothmoorthkumar

I can't help you with that little information sir.

Foxandxss avatar Jun 30 '16 10:06 Foxandxss

Hi Foxandxss,

behalf of @vinothmoorthkumar i'm asking this

actually we include "toastr" in angular controller

angular.module('shopshy.productDetail', []) .controller('productDetailCtrl', productDetailCtrl); productDetailCtrl.$inject = ['toastr'];

function productDetailCtrl(toastr) { toastr.success('success'); }

if we use toastr.success it is giving error : "Target for toasts doesn't exist"

naveencasp avatar Jun 30 '16 10:06 naveencasp

Are you overriding the toastr options?

Foxandxss avatar Jun 30 '16 10:06 Foxandxss

yes

naveencasp avatar Jun 30 '16 10:06 naveencasp

i'm over writing toastr with this config file. if i'm removing this its working fine but i need toastr in specific div that's why i wrote config file. code: .config(function(toastrConfig) { angular.extend(toastrConfig, { autoDismiss: true, maxOpened: 1, tapToDismiss: false, closeButton: true, closeHtml: '', target: 'notify', containerId: 'notify', onShown: function() { $("body").animate({scrollTop: $('#notification').offset().top}, "slow"); } }); })

naveencasp avatar Jul 27 '16 05:07 naveencasp

You are doing it wrong and is probably my fault. Is not really clear from my readme.

Basically the toasts goes to a new container that is created as soon as you put your first toast (and disappear when there is none). That container is going to be created yes or yes with the id containerId.

Then that container will be put on the body or if you want to put it in a different place, you give the id of that different target with target.

In this case, you are adding a new container named notify in a target called.... notify. That won't work. Notify doesn't exist in your dom so it fails.

Foxandxss avatar Jul 27 '16 09:07 Foxandxss