angular2 binding applies only after mouse movement

巧了我就是萌 提交于 2019-12-24 08:12:47

问题


I'm a new angular2 development and currently facing a rendering issue with my application. I use @angular@2.0.0-rc.1 for my app and router-deprecated@2.0.0-rc1 for my routing, whenever I click on the a link, the static content of the page loads immediately and the binding (dynamic content) happens only when I do some interaction with the mouse like click or hover over a link. I tried various options and still couldn't figure it out.

Any help would be appreciated.


回答1:


The order in which you include the JS files is important. This issue happened when I didn't.

<script src="/lib/shim.min.js"></script>
<script src="/lib/system.js"></script>
<script src="/lib/system-polyfills.js"></script>
<script src="/lib/Reflect.js"></script>
<script src="/lib/zone.js"></script>



回答2:


As mentioned by bryanm, the order of the js files is important and the placement of those script tags also matters. In my environment with angular2.rc.4, the order was

<script src="node_modules/es6-shim/es6-shim.js">
<script src="node_modules/reflect-metadata/Reflect.js">
<script src="node_modules/systemjs/dist/system.src.js">
<script src="node_modules/zone.js/dist/zone.js">

It has to be placed at the end of the body tag just above loading the systemjs config script.



来源:https://stackoverflow.com/questions/38793490/angular2-binding-applies-only-after-mouse-movement

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