angular-toastr
angular-toastr copied to clipboard
Allow template strings.
Currently, the template for a toast is specified by the templateUrl
. It would be nice to be able to use template strings. This would also eliminate the need to use $templateCache
.
I am not sure if I follow your issue.
You can override your templates by overriding the configuration.
The problem is, you cannot get rid of $templateCache
. The Angular core team recommends you to always use $templateCache
to avoid side effects.
For example in this library, if the template takes a bit longer than needed, it won't work (because I need to initialize toasts by hand). So if you don't have your templates cached, you will end with a first blank toast. Check angular/angular.js#12098.
That said, there is a workaround/hack to allow that, but I tried it and it needs to change lot of stuff along the way. I am planning to do major reworks for 2.0.0 but I am really busy with ui-bootstrap / ng-bootstrap so I can't barely give time to this.
Now, if I misunderstood your petition, please reword it :P
It is possible to use the template
property of a directive to set an inline template (example from angular docs).
I'd like to be able to use toastr with the a configuration similar to:
var module = angular.module('app', ['toastr']);
module.controller('foo', ['toastr', function (toastr) {
var ctrl = this;
ctrl.name = 'foobarbaz';
toastr.success('Hello world', 'foobar', {
template: {
toast: 'Hello {{ctrl.name}}!'
}
});
}]);
I see what you mean now. I will have to leave this on hold because I think I can do better for 2.0.0.
With the 2.0.0 version I want to lift the prohibition that I have with no supporting angular directives on messages / titles and if I do that, you will simply be able to:
toastr.success('Hello {{ctrl.name}}!');
I haven't give too much thought to that atm, but that is what I expect it to be.