使用的插件:https://github.com/Foxandxss/angular-toastr
我的目的是创建一个遍布页面的toastr和according to the documentation positionClass: 'toast-top-full-width'
,toastr.success('Hello world!', 'Toastr fun!', {
positionClass: 'toast-top-full-width'
});
就可以了。
.toast-top-full-width {
top: 0;
right: 0;
width: 100%;
}
查看插件css还可以验证声明。
for
但不知何故,代码不起作用。我的代码怎么了?
普兰克:http://plnkr.co/edit/2O6hjk5vnMUWWULNK9hs?p=preview
答案 0 :(得分:2)
您需要在angular config中配置toast。
var app = angular.module('app', ['ngAnimate', 'toastr']);
app.config(function(toastrConfig) {
angular.extend(toastrConfig, {
positionClass: 'toast-top-full-width'
});
});
app.controller('toastr-demo', function($scope, toastr) {
toastr.success('Hello world!', 'Toastr fun!');
});
答案 1 :(得分:1)
您的问题是toastContainer
不够大,您应该添加如下配置:
app.config(function(toastrConfig) {
angular.extend(toastrConfig, {
positionClass: 'toast-top-full-width'
});
});
这样,你所有吐司的容器都是全宽的,然后当你打电话给吐司时,你可以把他的大小设置为全宽。