簡體   English   中英

隱藏在ng-click元素之外的ng-hide

[英]Ng-hide outside ng-click elements

我正在使用ng-hide隱藏提示。 ng-click按鈕在表格中。 當我單擊ng-click按鈕時,它會隱藏表格。 問題出在我桌外還有ng-hide時。 單擊ng-click對ng-hide沒有影響。 下面是一個例子。

<p ng-hide="dismiss"><b>We found the below information on your social media profile. Would you like to import it into your information below?</b></p>

<table ng-hide="dismiss" ng-if="auth0.user.provider == 'instagram' || auth0.user.provider == 'google-oauth2'" class="application {{auth0.user.provider}}">
<tr>
    <td><img class="circle" src="{{auth0.user.picture}}"/></td>
    <td>{{auth0.user._json.name}}, unfortunatly {{auth0.user.provider}} does not provide enough data to import, please fill in below.</td>
    <td><button ng-click="dismiss = true">Dismiss</button></td>
</tr>
</table>

該表將隱藏,但p標記中的內容保留。 當我將其移到桌子外時,兩者都會隱藏。 我喜歡表格中的格式,看不到是什么原因造成的。

ng-if創建一個子范圍。 嘗試此測試-暫時從表中刪除ng-if 現在,單擊按鈕時,段落和表格都應該隱藏。 您是否可以將ng-if條件合並到表格的ng-hide中?

那是因為ng-if創建了一個新的作用域。 嘗試使用對象而不是基元。 意思是,除了使用dismiss ,您還可以執行以下操作:

控制器:

$scope.control = {};

HTML:

<p ng-hide="control.dismiss"><b>We found the below information on your social media profile. Would you like to import it into your information below?</b></p>

<table ng-hide="control.dismiss" ng-if="auth0.user.provider == 'instagram' || auth0.user.provider == 'google-oauth2'" class="application {{auth0.user.provider}}">
<tr>
    <td><img class="circle" src="{{auth0.user.picture}}"/></td>
    <td>{{auth0.user._json.name}}, unfortunatly {{auth0.user.provider}} does not provide enough data to import, please fill in below.</td>
    <td><button ng-click="control.dismiss = true">Dismiss</button></td>
</tr>
</table>

暫無
暫無

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

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