这通过注册一个
emHeightSource名为every
的观察者来工作
$digest。它会更新该
__height属性,该属性又将在监视
emHeightTarget:
.directive( 'emHeightTarget', function() { return { link: function( scope, elem, attrs ) { scope.$watch( '__height', function( newHeight, oldHeight ) { elem.attr( 'style', 'margin-top: ' + (58 + newHeight) + 'px' ); } ); } }} ).directive( 'emHeightSource', function() { return { link: function( scope, elem, attrs ) { scope.$watch( function() { scope.__height = elem.height(); } ); } }} )
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)