0
我想做一個套接字處理程序。所以在我的角色2代碼中,我得到了一個名爲「socket.service.ts」的服務。加載角度2服務內的動態服務
此服務導入套接字io lib並創建套接字。
但我試圖從json文件中獲取不同的處理程序。 例如: 用戶在config.json文件中編輯「處理程序」鍵,它應該更改套接字的處理程序。
我想這個處理程序有一個角2服務語法。所以我試圖導入這個動態服務與
System.import(path).then()
但它給了我一個錯誤。
這裏是我的socket.service:
private _byHandler() {
var _this = this;
this._initHandler((socketHandler) => {
_this.config = socketHandler.getConfig(_this.config);
_this._handler = socketHandler;
_this._createSocket();
});
}
private _initHandler(callback) {
let _this = this,
handler = this.config.handler,
path = "./../handlers/socket/" + handler + "/" + handler + "handler";
System.import(path).then(callback);
}
謝謝!