我正在尝试根据段落中没有行来显示更多/更少的指令。我无法得到段落所呈现的确切高度。
如何获得?
app.directive('moreLess', function(){
return{
restrict: 'AE',
scope: {
mlText: '@'
},
template:"<span>{{mlText}}</span>",
compile: function(elem, attributes){
return {
post: function(scope, elem, attributes, controller, transcludeFn){
var lineHeight = elem.css('lineHeight');
//var lines = elem[0].height;
console.log(elem[0].offsetHeight);
console.log(elem[0].scrollHeight );
console.log(elem[0].parentNode.scrollHeight );
console.log(elem.css('height'));
}
}
},
controller: function($scope){
}
}
})