我使用模式選項卡,並且我有通知彈出窗口,當他登錄到我的應用程序時,彈出窗口總是顯示給用戶。它包含用戶離線時發生的所有事件。問題是當我點擊列表中的任何對象時,它會關閉我的彈出窗口並顯示新的模式選項卡。
我想實現此功能。當用戶登錄時,通知彈出窗口將顯示給用戶,如果他點擊任何對象,它將打開另一個窗口而不關閉我的通知彈出窗口(新事件)。我想在下面的圖片上寫下類似的東西。
我檢查角材料的文檔,但沒有演示所有甚至沒有很好地解釋瞭如何使用multiple: true
選項工作,我不知道到底如何使它工作像我想要的。
https://material.angularjs.org/latest/api/service/ $ mdDialog
這是我用來顯示通知的彈出窗口代碼。
//show new notifications when user log in
NotificationService.getUnreadedNotifications(function (data) {
//initialization
$scope.notification = [];
$scope.OverAllCount = 0;
$scope.messageNotification = [];
$scope.OverAllMessageCount = 0;
if (data.ProjectNotifications != null) {
angular.forEach(data.ProjectNotifications, function (key, value) {
$scope.notification.push(key);
$scope.OverAllCount = $scope.OverAllCount + 1;
});
}
if (data.TasksNotifications != null) {
angular.forEach(data.TasksNotifications, function (key, value) {
$scope.notification.push(key);
$scope.OverAllCount = $scope.OverAllCount + 1;
});
}
if (data.MessageNotifications != null) {
angular.forEach(data.MessageNotifications, function (key, value) {
$scope.OverAllMessageCount = $scope.OverAllMessageCount + 1;
$scope.messageNotification.push(key);
});
}
popUpNotification();
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
//mark notifications as readed when user click on notification
function popUpNotification() {
$mdDialog.show({
controller: NotificationController,
templateUrl: 'app/components/templates/PopUpNotification.html',
parent: angular.element(document.body),
//targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false,
scope: $scope,
multiple:true,
preserveScope: true,
onComplete: function() {
$scope.notificationPopUp = $scope.notification;
}
})
.then(function() {
}, function() {
//fail
});
}
});
這是用於顯示在其上用戶點擊在新的模態重疊標籤
//mark notifications as readed when user click on notification
$scope.popUpDetail = function (notification, index, ev) {
$mdDialog.show({
controller: NotificationController,
templateUrl: 'app/components/templates/TaskDetailsDialog.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: false,
scope: $scope,
multiple: true,
preserveScope: true,
onComplete: function() {
//was readed => update database
NotificationResourceService.update({ id: notification.Id }, notification);
$scope.OverAllCount -= 1;
$scope.notification.splice(index, 1);
TaskService.get({ id: notification.EntityId })
.$promise.then(function (task) {
$scope.task = task;
});
}
})
.then(function() {
}, function() {
//fail
});
}
如果這是真的,我不明白爲什麼他們也有這自己的文檔中:「使用了$ mdDialog服務的多個選項,允許開發者顯示多個對話在同時「 – Martin
所以我找到了解決我的問題的工作方案。無論如何感謝您的時間。 – Martin