私はJavaScriptServices ng2スターターキット(https://github.com/aspnet/JavaScriptServices)から作成した非常に小さく簡単なアプリを持っています。
私はsignalrハブに接続し、サービスでこれを実行しようとしています。私はjQueryのlibには見つけることができないので、これは知っている...しかし、私はエラーと言ってを見ていますこれを行うにはjqueryの$の.hubconnectionを使用する
Exception: Call to Node module failed with error: Error: Uncaught (in promise): ReferenceError: $ is not defined
をしようとしています。誰かが私が間違っていることを知っていますか?
私のサービスの開始は、次のようになります...
import { Injectable, EventEmitter } from '@angular/core';
declare var $;
@Injectable()
export class SignalRService {
private proxy;
private proxyName: string = 'dateHub';
private connection;
public foodchanged: EventEmitter<any>;
public connectionEstablished: EventEmitter<Boolean>;
public connectionExists: Boolean;
constructor() {
this.foodchanged = new EventEmitter();
this.connectionEstablished = new EventEmitter<Boolean>();
this.connectionExists = false;
this.connection = $.hubConnection('http://localhost:5000/' + 'signalr/');
// this.proxy = this.connection.createHubProxy(this.proxyName);
// this.registerOnServerEvents();
// this.startConnection();
}
私の完全なコードは、私がここにいくつかの助けを本当に感謝https://github.com/bencameron00/Ng2JQueryHub
でgithubのです。私は非常に立ち往生しています。
あなたは "jqueryの" を追加する必要があります
おかげで動作します
、私はすでに "jqueryの" 参照ました: "^ 2.2.4を"。バージョンによって違いはありますか? –
また、サービスまたはindex.htmlにインポートを追加しますか? –
polyfil/main.tsに入れておくといいです。 –