2015-01-09 36 views
0

使用複選框如何隱藏和顯示範圍。 如果複選框被選中的跨度應該是dispaly,如果取消選中採用了棱角分明如何使用角度來更改複選框來隱藏和顯示div?

這裏是一個撥弄它不應該顯示:http://jsfiddle.net/d9uc1dxc/2/

<div class="flw vreq2"> 
     <label>Voting require2</label> 
     <div class="oneline"> 
     <div class="onoffswitches"> 
     <input type="checkbox" name="onoffswitch" class="onoffswitch- 
     checkbox"id="myonoffswitch7"/> 
       <label class="onoffswitch-label" for="myonoffswitch7"> 
        <span class="onoffswitch-inner"></span> 
        <span class="onoffswitch-switch"></span> 
       </label> 
     </div> 
     <span class="teamsize"> 
     <label>Team Size</label><input type="text" /> 
     </span> 
     </div> 
     </div> 

回答

2

使用這樣的:

<input type="checkbox" ng-model="val" ng-true-value="true" ng-false-value="false"/> 
    <span ng-show="val">hello world</span> 
0

你的小提琴例子表明,你甚至還沒有自舉AngularJs。你確定你選擇了正確的標籤嗎?你想在AngularJs中解決這個問題嗎? 如果是的話,我會建議你先通過AngularJs的基礎知識。 這裏是你的問題的答案。

你的HTML必須看起來像

<html ng-app="plunker"> 

    <head> 
    <meta charset="utf-8" /> 
    <title>AngularJS Plunker</title> 
    <script>document.write('<base href="' + document.location + '" />');</script> 
    <link rel="stylesheet" href="style.css" /> 
    <script data-require="[email protected]" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js" data-semver="1.3.7"></script> 
    <script src="app.js"></script> 
    </head> 

    <body ng-controller="MainCtrl"> 
    <p>Hello {{name}}!</p> 

    <input type="checkbox" ng-model="checkBoxValue" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch7"/> 
       <label class="onoffswitch-label" for="myonoffswitch7"> 
        <span class="onoffswitch-inner"></span> 
        <span class="onoffswitch-switch"></span> 
       </label> 

     <div ng-hide="checkBoxValue"> 
     <span class="teamsize"> 
     <label>Team Size</label><input type="text" /> 
     </span> 
     </div> 


    </body> 

</html> 

參見:http://plnkr.co/edit/sc2xRQCYOi22D9AYqCrX?p=preview

0

我找到了最好的答案

<input type="checkbox" name="onoffswitch" class="onoffswitch- 
     checkbox"id="myonoffswitch7" ng-model="checked" /> 

<span class="teamsize" ng-hide="checked"> 
    <label>Team Size</label><input type="text" /> 
</span> 
相關問題