Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs toastr:在右下角显示toast_Javascript_Html_Angularjs_Toast_Angular Services - Fatal编程技术网

Javascript Angularjs toastr:在右下角显示toast

Javascript Angularjs toastr:在右下角显示toast,javascript,html,angularjs,toast,angular-services,Javascript,Html,Angularjs,Toast,Angular Services,我不习惯使用。我的问题是如何覆盖positionClass并在右下角显示toast 我知道你可以在html中使用选项来实现这一点,但我不希望在我的html中这样做。我有20个积垢的网页,我需要管理。为每个页面添加内容是不正确的。因此,我将toast用作服务,我可以在每个crud的控制器中使用它 (function() { "use strict"; angular.module("app").factory('ToastService', functi

我不习惯使用。我的问题是如何覆盖positionClass并在右下角显示toast

我知道你可以在html中使用
选项来实现这一点,但我不希望在我的html中这样做。我有20个积垢的网页,我需要管理。为每个页面添加内容是不正确的。因此,我将toast用作
服务
,我可以在每个crud的控制器中使用它

     (function() {
        "use strict";

        angular.module("app").factory('ToastService', function($mdToast, toastr) {


            //http://codeseven.github.io/toastr/demo.html
            toastr.options = {
                "closeButton": false,
                "debug": false,
                "newestOnTop": false,
                "progressBar": false,
                "positionClass": "toast-bottom-right",
                "preventDuplicates": false,
                "onclick": null,
                "showDuration": "300",
                "hideDuration": "1000",
                "timeOut": "6000",
                "extendedTimeOut": "1000",
                "showEasing": "swing",
                "hideEasing": "linear",
                "showMethod": "fadeIn",
                "hideMethod": "fadeOut"
            };

      return {

                info: function(content, title) {
                    if (!content) {
                        return false;
                    }

                    return toastr.info(content, title, {
                        timeOut: toastr.options.timeOut
                    });
                },


                success: function(content, title) {
                    if (!content) {
                        return false;
                    }

                    return toastr.success(content, title, { timeOut: toastr.options.timeOut});
                },

        error: function(content, title, time) {
            if (!content) {
                return false;
            }
            return toastr.error(content, title, {
                timeOut: time
            });
            //
        },

        };
    });
})();
在控制器中,我这样称呼它

  ToastService.error('Connection interrupted!', 'Server Error');
但是我想在右下角显示它,而不是右上角的默认位置


谢谢

toastr从右下角为我弹出,通过设置以下选项:

config.js(cref:)
你有CSS问题吗?

你在这里写了完整的代码吗?我看不到中的错误函数ToastrService@UmairFarooq更新!它基本上是相同的.toastr.error(内容、标题、{timeOut:time});这样做可能会覆盖默认选项。@UmairFarooq我已经更新了代码。我不知道你是什么意思?我知道我可以覆盖超时,但我想更改主问题中提到的默认位置。谢谢可以给我一些JSFIDLE或plunket示例吗?因为您还没有发布控制器代码。您将这些代码放在了哪里?请参阅修订后的答案
(function () {
    var app = angular.module('app');
    // Configure Toastr
    toastr.options.timeOut = 4000;
    toastr.options.positionClass = 'toast-bottom-right';
    toastr.options.showMethod = 'slideDown';
    toastr.options.hideMethod = 'slideUp';
    var config = {
        version: '1.1.0',
        ...
    };
    app.value('config', config);
})();