SignalR's $.hubConnection() is not a function

依然范特西╮ 提交于 2020-01-05 03:34:30

问题


Hi All i'm working on Implementing a SignalR Stock Ticker Using AngularJS based on an example over here. But i'm getting an error while connecting to signalr like this TypeError: $.hubConnection is not a function

And this is where the error is showing:

var initializeClient = function () {
      //Creating connection and proxy objects
       console.log("anil");
       connection = $.hubConnection();
       //console.log("anil.r");
       proxy = connection.createHubProxy('stockTicker');

       configureProxyClientFunctions();

       start();
        };

Since I'm new to working on signalr , have got lots of confusion in it can anybody help me out of this .


回答1:


  1. npm install -s signalr
  2. Add the next lines to angular-cli.json

    "scripts": [
    
    ...
    "../node_modules/signalr/jquery.signalR.js"
    
    ],
    



回答2:


  1. Make sure it is added, if your project version Angular 6+ add the next lines to angular.json
  2. Re-compile project.

    "scripts": [

    ...

    "node_modules/jquery/dist/jquery.js",

    "node_modules/signalr/jquery.signalR.js"

    ],



来源:https://stackoverflow.com/questions/40890506/signalrs-hubconnection-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!