如何从此指令中获得el
的宽度?
angular.module('carouselApp')
.directive('waProgress', ['Pages', 'Carousel', '$window', '$timeout', function(Pages, Carousel, $window, $timeout) {
return {
scope: {
pages: "="
},
templateUrl: 'views/wa.progress.html',
transclude: true,
require: '^waCarousel',
link: function(scope, el, attrs, ctrl) {
// console.log();
scope.progressed = false;
scope.$root.subscribe('updateCarousel', function(params){
// console.log('asdfasdf', params);
scope.progress = params;
scope.passedProgress = function(idx){
if(scope.progress.currentPage > idx){
console.log(el.width());
return scope.progressed = true;
// scope.animatedWidth = $
}
}
});
scope.futureProgress = function(idx) {
console.log(idx)
};
}
}
}]);
答案 0 :(得分:2)
试试这个,
Use element[0].offsetWidth