admin管理员组文章数量:1429327
I have code looking like this :
<table>
<tr>
<td>Hello</td> <!-- td1 -->
<td ng-show="var">how are</td> <!-- td2 -->
<td ng-hide="var">you</td> <!-- td3 -->
</tr>
</table>
The td1 is correctly hidden, but when td2 is hidden it create an empty gap. I'd like td2 to be fully replaced by td3.
Using only AngularJS and not jQuery would be cool.
I have code looking like this :
<table>
<tr>
<td>Hello</td> <!-- td1 -->
<td ng-show="var">how are</td> <!-- td2 -->
<td ng-hide="var">you</td> <!-- td3 -->
</tr>
</table>
The td1 is correctly hidden, but when td2 is hidden it create an empty gap. I'd like td2 to be fully replaced by td3.
Using only AngularJS and not jQuery would be cool.
Share Improve this question edited Feb 6, 2016 at 21:30 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Feb 20, 2015 at 9:59 IggYIggY 3,1454 gold badges32 silver badges55 bronze badges 2- can you explain what you mean by empty gap ? i can not reproduce it plnkr.co/edit/Dbw7VGmQu8s75cGEmhrG?p=preview – micha Commented Feb 20, 2015 at 10:20
- ng-hide set css to display:none. so there should be no gap. it is not set to visibility: hidden. So your gap has a other reason. please provide your real code – micha Commented Feb 20, 2015 at 10:31
2 Answers
Reset to default 4You should use ng-if
instead of ng-hide
. ng-if
will actually remove the element from the DOM.
ng-show
/ng-hide
simply changes the display
css property of your element.
For example:
<table>
<tr>
<td>Hello</td> <!-- td1 -->
<td ng-if="var">how are</td> <!-- td2 -->
<td ng-if="!var">you</td> <!-- td3 -->
</tr>
</table>
See the documentation if you use animations and want them to work like with ng-show
/ng-hide
.
Use "ng-if" instead of "ng-show". For example:-
<table>
<tr>
<td>Hello</td> <!-- td1 -->
<td ng-if="var==true">how are</td> <!-- td2 -->
<td ng-hide="var==false">you</td> <!-- td3 -->
</tr>
</table>
本文标签: javascriptAngularJShide lttdgt without gap using nghidengshowStack Overflow
版权声明:本文标题:javascript - AngularJS : hide <td> without gap using ng-hideng-show - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745506849a2661284.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论