被杀后的ui通知痕迹

时间:2017-05-15 05:26:33

标签: angularjs twitter-bootstrap css-transitions

如何删除ui通知的痕迹 这些通知使用户无法单击按钮 甚至通知在用户打算再次指向其弹出时被杀死,阻止用户按下按钮。

[Notification is already killed [1]

我的控制器代码

 $scope.loginForm = function(isValid) {
    // $window.location.href = '/home';
    $scope.submitted = true;
    if (isValid) {
        service.login({
            data: {
                user: $scope.login
            }
        }).then(function(response) {
            authService.isLoggedIn = response.status == "success";
            if (response.status == "success") {
                authService.set("userInfo", response.data)
                authService.role = response.data.role;
                authService.name = response.data.name;
                Notification.success({message:'Successfully logged in'});
                // Notification.clearAll("Successfully logged in");
            }
            else{
                Notification.success('Invalid Credentials');
            }
            // console.log(response.data.redirect)
            $location.path(response.data.redirect); 
        });
    } else {
        Notification.error('Error Login');
    }
}; 

1 个答案:

答案 0 :(得分:1)

选项1:App Config

app.config(["NotificationProvider", function (notificationProvider) {
    notificationProvider.setOptions({
            delay: 1000,
            startTop: 20,
            startRight: 10,
            verticalSpacing: 20,
            horizontalSpacing: 20,
            positionX: 'left',
            positionY: 'bottom'
        });
    }]);
  

您可以在app config上使用延迟选项来更快地隐藏消息,如果没有,请转到选项2

选项2:进行外部服务

    app.service("closeNotify", function ($timeout) {
        this.closeNotification = function (time) {
            $timeout(function() {
                $(".message").click();
            }, time);
        }
    });
  

在此服务中,我们使用“jQuery”来处理 click()功能,弹出消息之后我们将服务设置为在特定时间后隐藏消息,转到如何使用

如何

    app.controller("ctrl", ["$scope", "Notification", "closeNotify", 
    function (scope, notification, closeNotify) {

        notification.primary('Primary notification');
        closeNotify(1000);
    }]);