javascript - Angular: Selecting elements from DOM -
i'm using ng-repeat create items. determine height of each element created using function.
i know how pass index of element created ng-repeat function should determine height, i'm getting stuck in selecting item.
this i'm using now:
   $scope.getitemheight = function(index) { // index index of element in ng-repeat     var itemheight = angular.element('li').eq('+index+').offsetheight;     return itemheight;    };   but doesn't work due error: error: [jqlite:nosel] looking elements via selectors not supported jqlite!
i tried:
   $scope.getitemheight = function(index) {     var itemheight = document.queryselectorall('ul:nth-child('+index+')');     return itemheight;    };   this returns element length 0 selector doesn't work.
what missing here?
codepen here: http://codepen.io/squrler/pen/lxsfe?editors=101
edit: want not possible @ time. more information here: https://github.com/driftyco/ionic/issues/1691
edit: after looking @ further seems bit more complicated. directive firing repeater needs run in order lis rendered, li rendered (assuming move directive) triggers directive height, li , it's corresponding data not yet rendered , have no height. if wait rendering using timeout, repeater continue rendering without valid height data while timeout waits. seems have bit of conundrum. might try using http://binarymuse.github.io/nginfinitescroll/ or of like.
this should put in directive give easy access li rendered.
something like:
.directive('getheight', ['$filter', function ($filter) {     'use strict';      return {         restrict: 'a',         scope: true,         link: function (scope, element, attrs) {             var li = element[0];             var height = li.offsetheight;             console.log('height': height)         }     }; }]);   not sure you're looking height once have it...
otherwise can go:
var ul=document.getelementsbytagname('ul')[0]; var li=ul.getelementsbytagname('li')[index]; var height=li.offsetheight;      
Comments
Post a Comment