想用ng 做一个轮播,可是在link 无法获取dom的元素
.directive("carousel",[function (){
return {
replace:true,
restrict:"EA",
scope:{
img:"=myImage"
},
transclude:true,
templateUrl:'../js/template.html',
link:function(scope,elem,attr){
var t=document.querySelectorAll(".carousel ul li");
console.log(t);
}
}
}]);
-
link不是应该在渲染完后加载的吗?为什么显示 空呢??求教
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
$element 就是 jqlite 对象,用它就行了。
一个例子,公司实习生练习例子
https://github.com/ShuyunXIAN...
直接把他封装成轮播组件,不需要操纵获取dom什么的。