-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: newToast.scope.init is not a function #109
Comments
Weird, but if you're using a different template, don't use the tpls version, but still it shouldn't fail. |
i tried many capabilities, but none works |
I see. I would need a reproduction (plunker for example) to be able to test that myself. Or better you could look into the problem and send a PR :) |
i have something like this: http://plnkr.co/edit/RJaDKSJZk3hSSOrfQ9nv |
I need a working reproduction, that plunker outputs a lot of errors. |
there it is, working |
I see it. Really weird. Will investigate. |
Give me some information please. How are you loading the template in your solution? It is a .html file you fetch, it is on templateCache... I can't reproduce it on my local playground. |
Ok, I see where the problem is, now for a fix. |
I created an issue at the angular repo, I am not sure if the problem is mine or not. |
So the issue is mine, I will think about a way of fixing it. In the meantime I highly recommend you to cache all your templates before booting the app. It is a common thing to do and will fix this issue for now. |
I tried to fix this but there are some limitations in angular. In the time being I highly recommend you (if you still use this library) to put your template in $templateCache if possible. |
I did it. Hope it will be fixed in the future. |
I am having some talks with a few folks and they all think the same. The end user has to cache their templates beforehand. I agree with them, it is a sane thing todo. The problem is that angular itself doesn't have some facilites to allow $animate to wait until the directive is compiled (with its children) and I would need to break half library to hack it. So I am sorry, not a supported feature. Will add a note in the readme. |
Reading this issue and the note in the README I understand that this the problem would happen only with custom templates, but I'm using the provided template, i.e. |
@dcardosods If you manage to reproduce it in a plunker, please create a new issue so I can take a peek. |
Same problem. |
I think i will use https://www.nuget.org/packages/toastr. It is working. |
That will work for sure (if you don't mind the extra dep). It is not like I don't want to fix the error, but I can't spend dozen of hours trying everything to find your issue. I really need a way to know how you managed to get the error so I can see it myself, create a test and fix it. I can't do it blind. |
@Foxandxss I couldn't manage to isolate the problem. Even on my application it's happening intermittently. |
Same problem on angular 1.4 @Foxandxss UPDATE: Tried using tpls version and it worked. |
@artdias90 Would you be kind to create a reproduction? #129 Thanks. |
If the error doesn't show up, what issue are you seeing in that case? |
I would like to use toastr.clear without errors.
|
I understand, this issue is very problematic but hard to fix. What error do you get @tmundt ? I will give time to this issue next week and try to release a new version. |
Just got this, just took over a project using ng-toastr ... I don't have the background on this, but I see the toast is working, and here a certain Here it's expected, and my fix is inside:
|
I thought about that, but if there is some "legit" toast in there that wants to show up and the I pushed a new update to master that removes Since I don't have a reproduction I can try, I would love other people having the issue to check it out and see if that new master version does the job. |
Can I mail you a link. Don't want to post it here openly |
Of course |
I ran into the same issue and used the fix from Björn to make it work. |
still occurs in the 1.7.0 |
I will release a new version without |
many thanks |
What's the status on this issue? I am having the same problem with I am using I am also wrapping all the toastr functionality in a custom injectable service (see below). Whether I inject or not the toastrConfig into that service or not to configure things like the target (because sometimes I want validation errors to be displayed in a specific The error happens always when a toastr is already on screen (i.e: if I call another function before it disappears) even if I clear all the toastr before invoking the new one.
|
It should be fixed, but apparently not. Would you be able to reproduce this in a plunker or a little project at github? I would like to try. |
I have this issue only when I minify. I speculate that the async animate functionality loses context somehow? I might try to refactor and not use scope and see if that helps :) Cool library! |
"if you're using a different template, don't use the tpls version" .. how can i prevent using the tpls version ? [edit - sorry - that was obvious, i was including it in the html, just hadn't noticed.] |
i had this intermittently, so it seemed like a timing option. wrapping it in a timeout, which gives it a single cycle more, seems to solve it here .. sofar ..
needed to do it twice in angular-toastr.js when not using angular-toastr.tpls.min.js |
When can this be resolved and merged: #178 |
I never confirmed that that fix works. I am sorry for not responding, but my job is soo consuming lately. |
THE FIX: I've had this problem for ages and just ignored it, but I finally got to it. Someone here even pointed it out and it worked. $templateCache. app.config(function (toastrConfig:any) {
angular.extend(toastrConfig, {
allowHtml: false,
closeButton: false,
closeHtml: '<button>×</button>',
extendedTimeOut: 1000,
iconClasses: {
error: 'toast-error',
info: 'toast-info',
success: 'toast-success',
warning: 'toast-warning'
},
messageClass: 'toast-message',
onHidden: null,
onShown: null,
onTap: null,
progressBar: false,
tapToDismiss: true,
templates: {
toast: 'toast.html',
progressbar: 'progressbar.html'
},
timeOut: 5000,
titleClass: 'toast-title',
toastClass: 'toast'
});
});
app.run(['$templateCache',function ($templateCache:any) {
$templateCache.put('toast.html', `
<div class="{{toastClass}} {{toastType}}" ng-click="tapToast()">
<div ng-switch on="allowHtml">
<div ng-switch-default ng-if="title" class="{{titleClass}}" aria-label="{{title}}">{{title}}</div>
<div ng-switch-default class="{{messageClass}}" aria-label="{{message}}">{{message}}</div>
<div ng-switch-when="true" ng-if="title" class="{{titleClass}}" ng-bind-html="title"></div>
<div ng-switch-when="true" class="{{messageClass}}" ng-bind-html="message"></div>
</div>
<progress-bar ng-if="progressBar"></progress-bar>
</div>`);
$templateCache.put('progressbar.html', `<div class="toast-progress"></div>`);
}]); you'll notice that I changed the config so toast.html and progressbar.html have no paths. I think the problem was simply that the template just didn't load fast enough. Was driving me nuts, because I couldn't get it to happen on my local server, but the production machine had the bug. Anyway, if you're having trouble, try just cutting and pasting that code into yours. If it works, boom, you're done. |
Solution provided by danielcmorris is working, I have tested it and deployed in Production. |
A slight clarification to @danielcmorris solution: |
I'm using angular-toastr in my project and i've got this error, when first toastr appears.
Unfortunately, this error appear always on server (for first toastr) and only one on my local machine.
This is my config:
I'm inlcuding angular-toastr.tpls.js script in my html files.
The text was updated successfully, but these errors were encountered: