angular.js路由的时候不同的页面引入js问题
迷茫
迷茫 2017-05-15 17:02:39
0
4
468

用ng做框架,路由的时候发现一个问题。不同的页面要用到不同的js的时候,不起作用。我知道原因是你的这个js是需要获取到一些Dom节点的。 但是在最开始加载首页的时候我的这个页面并木有加载出来,这个时候就无法获取到这些 DOM节点,各位有好的解决办法吗?

迷茫
迷茫

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!