Different pages introduce js problems during angular.js routing
迷茫
迷茫 2017-05-15 17:02:39
0
4
530

Using ng as a framework, I found a problem when routing. It doesn't work when different pages use different js. I know the reason is that your js needs to get some Dom nodes. But when the homepage is first loaded, my page is not loaded. At this time, these DOM nodes cannot be obtained. Do you have any good solutions?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(4)
滿天的星座

The DOM event cannot take effect. There is a live method (jquery on). If the double binding of data fails, $scope.$apply() is manually refreshed. The loading of the DOM node is also related to the location where your js is written. Your question is not clear enough

滿天的星座

A frequently used method, use the $timeout method:

$timeout(function() {
    // TODO
    // 这里填写你的功能代码
}, 1000) // 这个时间你可以自己选择
给我你的怀抱

angular.element(document).ready()
Put js in ready and try it

滿天的星座

This problem has been solved. I also encountered it before and struggled with it for a long time. http://www.weipxiu.com/?p=434

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template