簡體   English   中英

動態隱藏html錨標記中的元素

[英]hiding an element in html dynamically which is in anchor tag

如何隱藏導航欄中定位標記內的元素? 我已經嘗試過ng-hide但無法正常工作。

    <nav class="navbar navbar-inverse text-" style="height: 60px;">
        <div class="container-fluid">

            <div class="collapse navbar-collapse" id="myNavbar">
                <img src="\assets\nextel.png">

                <a class="navbar-brand pull-right" [nghide]="x" [routerLink]="['login']" style=" margin-top: 32px;
                color: #000;"><span class="glyphicon glyphicon-log-in"></span>&nbsp;Login</a>

            </div>
        </div>
    </nav>

在這里我提到了[nghide]="x" ,其中x為真,它必須出現,否則無論我在錨標簽中提到的什么,它都必須消失。 但是每當我嘗試這樣做時,總的導航欄就會消失。解決方案是什么。

嘗試ng-hide="x"代替[nghide]="x"

您正在使用Angular而不是AngularJS。 如果我是正確的,則需要使用*ngIf

<a class="navbar-brand pull-right" *ngIf="x" [routerLink]="['login']" style=" margin-top: 32px;color: #000;"><span class="glyphicon glyphicon-log-in"></span>&nbsp;Login</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM