How to use Hammer in angular universal

馋奶兔 提交于 2021-02-04 20:00:30

问题


Can anyone pls help me to fix hammer error

})(window, document, 'Hammer');
^
 ReferenceError: window is not defined
at Object._MAP.8 (/Users/ks89/git/universal-starter/dist/server.js:126460:4)

in angular universal.


回答1:


You need to import hammer from main.ts, not directly from the module. That way, it won't be included server side

https://github.com/angular/material2/blob/master/guides/getting-started.md#step-5-gesture-support



来源:https://stackoverflow.com/questions/49335441/how-to-use-hammer-in-angular-universal

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