2017-05-15 34 views
-1

如何刪除用戶通知的跟蹤 這些通知讓用戶無法點擊按鈕 即使通知在用戶通過點擊重新指向其彈出窗口時死亡,阻止用戶按下按鈕。被殺後的用戶通知跟蹤

[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'); 
    } 
}; 
+0

喜怎麼樣,哪裏是你angularJs代碼!你的代碼在哪裏!你的樣本在哪裏幫助人們回答你的問題......請改善你的問題。 – Maher

+0

我單獨使用notification.success。我附上我的角碼 –

+0

「通知服務」,只是有一個「成功」的功能?去這個服務,並檢查它是否包括「關閉」或「清除」(類似的東西)功能。 – Maher

回答

1

選項1:應用程序配置

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

可以使用延遲選項在應用程序配置隱藏消息更快,如果沒有,去選項2

選項2:使外部服務

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

在該服務中,我們使用「jQuery的」處理點擊()功能,彈出我們確立了服務的消息後,在特定時間後隱藏信息,轉到如何使用它

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

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