2014-12-13 68 views
0

嗨我試圖隱藏引導程序按鈕。只有當我點擊一個複選框時,我才能看到它們。但我無法實現。任何人都可以幫忙嗎?無法隱藏引導程序按鈕

HTML

<input type="checkbox" ng-model="todo.done" value="{{todo.task_name}}"> 
<span class="done-{{todo.done}}"> {{todo.task_name}}</span>   
<a id="done-modal-button" ng-click='onCompleteTask(todo)' ng-model="todo.done" class="btn btn-xs btn-success">Done</a> 

JS

$('#done-modal-button').hide(); 
+1

#done-button或#done-modal-button? – 2014-12-13 18:37:03

+0

@ Bhojendra-C-LinkNepal對不起。 #done-modal-button – 2014-12-13 18:38:21

回答

1

您不需要Jquery來做到這一點! 你只需要改變這一行:

<a id="done-modal-button" ng-click='onCompleteTask(todo)' ng-model="todo.done" class="btn btn-xs btn-success">Done</a> 

要這樣:

<a id="done-modal-button" ng-click='onCompleteTask(todo)' ng-show="todo.done" class="btn btn-xs btn-success">Done</a> 

你要顯示的鏈接,只有當 「todo.done」 是真的

http://jsfiddle.net/HB7LU/9139/

我建議你閱讀這篇文章:

"Thinking in AngularJS" if I have a jQuery background?

+0

這工作得很好。我不想在這條線上做白癡。非常感謝@Fabrico。 – 2014-12-14 02:54:03

+0

偉大的回答,我不熟悉角,並想給他一個工作的答案,直到他找到了一個正確的方式:D +1從我:D – Alin 2014-12-14 13:43:40

0

嘗試使用CSS display:none來隱藏它:基於您的評論

<a id="done-modal-button" ng-click='onCompleteTask(todo)' ng-model="todo.done" class="btn btn-xs btn-success" style="display:none;">Done</a> 

更新

要根據天氣切換可見性,請選中複選框,或者不需要查看是否先檢查它,如果是,請顯示按鈕,否則將其隱藏回去。

$(document).ready(function() {  
    $('#checkboxid').click(function() { 
     if($(this).is(":checked")) 
     { 
      $('#done-modal-button').show(); 
     } else { 
      $('#done-modal-button').hide(); 
     } 
    }); 
}); 

Working JSfiddle

更新2

我想你有沒有其他的jQuery庫在腳本中,使用上面的方法,你可以在我給你的jsfiddle使用方法在評論或者你可以加載jquery-1.9.1,它會工作,看到這個JSFIDDLE與AngularJS和jQuery-1.9.1

要加載庫,只需將它添加到您的頭標記中:

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
+0

工作。非常感謝。任何關於如何讓它顯示的想法是勾選複選框。 – 2014-12-13 18:43:16

+0

@krish_cloud現在你想讓它在ckechbox被選中時可見並且不能被隱藏? – Alin 2014-12-13 18:45:28

+0

@krish_cloudnow我更新了我的答案,並且還添加了一個工作jsfiddle複選框的工作方式。如果這回答你的問題,隨時標記:) – Alin 2014-12-13 18:51:55