//滑动时二级菜单跟随滑动 zswApp.directive('scrollNav', function () { return { restrict: "A", scope: true, link: function ($scope, elm, attr, controller) { var navbox=$(".nav_box"); //得到导航对象 var scrollFn = function(){ var navbox=$(".nav_box"); //得到导航对象 $(".nav2_box").css("left",navbox.scrollLeft()); }; navbox.on('scroll',scrollFn); $scope.$on('$destroy',function(){ navbox.off('scroll',scrollFn); }) } } });
来源:https://www.cnblogs.com/vonson/p/9133428.html