Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 检测角度4中每个元素的最大宽度_Angular - Fatal编程技术网

Angular 检测角度4中每个元素的最大宽度

Angular 检测角度4中每个元素的最大宽度,angular,Angular,我试图在角度上做这个精确的函数,但根本不起作用,我的元素被ngIf隐藏,然后循环元素 这是在jquery中如何完成的: var maxWidth = Math.max.apply( null, $( 'div' ).map( function () { return $( this ).outerWidth( true ); }).get() ); alert( maxWidth ); 演示: 角度应该是多少?你不能测量用ngIf隐藏的东西的宽度,因为这些元素根本不存在于多面体上,我

我试图在角度上做这个精确的函数,但根本不起作用,我的元素被ngIf隐藏,然后循环元素

这是在jquery中如何完成的:

var maxWidth = Math.max.apply( null, $( 'div' ).map( function () {
    return $( this ).outerWidth( true );
}).get() );

alert( maxWidth );
演示:


角度应该是多少?

你不能测量用ngIf隐藏的东西的宽度,因为这些元素根本不存在于多面体上,我无法测量,但如果可见,我可以在之后进行测量,但在该标志设置为true后,代码将无法正常工作,我看不到任何其他解决方案,只有jquery函数如何使用隐藏元素[hidden]=true?您无法测量使用ngIf隐藏的内容的宽度,因为这些元素在dominded上根本不存在,我无法测量,但如果可见,我可以在之后进行测量,但在该标志设置为true后,代码将无法正常工作,我没有看到任何其他解决方案,只有jquery函数如何使用[hidden]=true隐藏元素?