1

Using checkbox how to hide and show the span. If checkbox is checked on the span should be dispaly, if uncheck it should not be display using angular

Here is a fiddle: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>

4 Answers 4

3

Use like this:

<input type="checkbox" ng-model="val" ng-true-value="true" ng-false-value="false"/>
    <span ng-show="val">hello world</span>
Sign up to request clarification or add additional context in comments.

Comments

0

you can use ng-show or ng-hide in the span tag. https://docs.angularjs.org/api/ng/directive/ngShow

Comments

0

Your fiddle example shows that you have not even bootstrapped AngularJs. Are you sure you selected a correct Tag? And you want to solve this issue in AngularJs? If yes, the I would suggest you first go through the basics of AngularJs. And here is an answer to your question.

your html must look like

<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>

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

Comments

0

I found the best answer

<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.