[英]Cannot read property 'notificationsHub' of undefined? SignalR with angularJS
//角度控制器
$scope.notification = $.connection.notificationsHub;
$scope.SendNotification = function (schoolId) {
$http({
url: "/Notifications/InsertNotification?SchoolId=" + schoolId+"&Notification="+$scope.Notification,
method: "GET"
}).then(function (res) {
console.log(res);
notification.client.sendNotification = function () {
getAllNotifications();
}
$.connection.hub.start().done(function () {
getAllNotifications();
}).fail(function (e) {
console.log(e);
alert(e);
})
function getAllNotifications() {
$http({
url: "/Notifications/Notifications?SchoolId=" + schoolId,
method: "GET"
}).then(function (res) {
console.log(res);
});
}
});
}
C#代码(集线器类)
public void Send()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<NotificationsHub>();
context.Clients.All.SendNotification();
}
我试图在owin启动类中添加地图,并且所有脚本都放置在正确的位置,并且尝试了很多解决方案,但它不起作用,我需要帮助:D
我发现一个解决方案说要从global.cs文件中注释或删除捆绑寄存器,似乎signalR的文件与bundleconfig.cs文件中的其他.js文件有冲突,并且解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.