【发布时间】:2017-09-16 15:37:36
【问题描述】:
我正在使用 laravel 和 angular js。在 laravel 中,我使用了事件广播和推送通知。在角度方面,我订阅了频道并收到了该通知。
现在,我已将推送数据存储到一个变量中并将其显示到 html 中。但是,当我重新加载页面时,通知会被删除。
Angular js:
Pusher.logToConsole = true;
var pusher = new Pusher('Pusher-key', {
cluster: 'ap2',
encrypted: true
});
var channel = pusher.subscribe('ticket-'+$login_user_id);
channel.bind('ticket-notification', function(data) {
var i = $scope.notification.length;
$scope.notification[i] = {"id":data.ticket.id,"subject":data.ticket.subject};
$scope.total_notification = $scope.notification.length;
console.log($scope.total_notification);
});
this.update_notification = function(notification_id,index) {
$scope.notification.splice(index,1);
$scope.total_notification = $scope.notification.length;
}
现在,我想全局存储 notification 变量。所以当我重新加载页面时,它不会影响该变量,也可以在另一个浏览器中显示。
那我该怎么办?
【问题讨论】:
标签: javascript angularjs laravel