Skip to content
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

Custom dynamic template #190

Open
shyamal890 opened this issue Jul 14, 2016 · 7 comments
Open

Custom dynamic template #190

shyamal890 opened this issue Jul 14, 2016 · 7 comments

Comments

@shyamal890
Copy link

I would like to dynamically change the toast template. Using the following code doesn't work, renders the same template:

templates: {
                    toast: 'App/views/Toast/custom-template.html'
                }
@Foxandxss
Copy link
Owner

my recommendation is that you $templateCache the template before you use it.

@shyamal890
Copy link
Author

Can't this work without caching the template? I have separate logic that triggers caching process for release build. This may create a conflict.

@Foxandxss
Copy link
Owner

The official recommendation from angular is to provide the templates already cached. The problem here is that you won't get a valid toast the first time you use it (because the toast will be shown before the template gets fetched) and there is no way around that for this kind of widgets.

@shyamal890
Copy link
Author

shyamal890 commented Jul 14, 2016

@Foxandxss Check this plunker. I tried creating toast more than 2 times, custom-template is not rendered.

http://plnkr.co/edit/FuXKAPkmOOM1IcqNRuIs?p=preview

May be I am doing something wrong.

@Foxandxss
Copy link
Owner

Custom templates can't be changed on the toast, needs to be changed on toastrConfig.

@shyamal890
Copy link
Author

Oh, that means I can only set one template at a time. I would like to render different templates for different toasts.

@Rhobal
Copy link

Rhobal commented Oct 28, 2016

I also tried to set a custom template, only to detect that the options "iconClasses" and "templates" are considered "bad Options" and are deleted in cleanOptionsOverride(options)
Cost me >two hours to find the real problem.
I am trying to set one toast with a custom template. This would mean I'll have to add a lot more ng-ifs and ng-selects to the standard template to incorporate all possibilities :-(

Please update the documentation; it now clearly says "The second option is to pass a third parameter". I have searched in vain for a hint that "templates" or "iconClasses" cannot be used for the second option.
I suggest you add "(can only be used toastConfig)" to the documentation of these two options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants