Foxandxss / angular-toastr

Angular port of CodeSeven/toastr.
http://foxandxss.github.io/angular-toastr/
MIT License
1.3k stars 276 forks source link

Target for toasts doesn't exist #187

Open vinothmoorthkumar opened 8 years ago

vinothmoorthkumar commented 8 years ago

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

Foxandxss commented 8 years ago

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

naveencasp commented 8 years ago

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"

Foxandxss commented 8 years ago

Are you overriding the toastr options?

naveencasp commented 8 years ago

yes

naveencasp commented 8 years ago

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"); } }); })

Foxandxss commented 8 years ago

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.