html - Showing and hiding content with AngularJS -


i trying tab between different content views using angular. starts out showing no content, , toggles between 2 views after clicking on option.

what want show first view on load, , let me toggle between two.

here current code:

<div ng-app="">   <div class="wrap">     <h1>hello there!</h1>     <p>push radio buttons change content!</p>     <form>        <label for="first">show first content</label>       <input id="first" type="radio" name="content" ng-model="content" value="first">       <br />       <label for="other">show other content</label>       <input id="other" type="radio" name="content" ng-model="content" value="other">     </form>      <div class="wrapper">       <p ng-show="content == 'first'">this first content!</p>       <h2 ng-show="content == 'other'">this other content!</h2>     </div>   </div> </div> 

http://codepen.io/er40/pen/nqwjro

use ng-init directive set initial value first. code help:

<div ng-app="">   <div class="wrap">     <h1>hello there!</h1>     <p>push radio buttons change content!</p>     <form>        <label for="first">show first content</label>       <input id="first" type="radio" name="content" ng-model="content" value="first" ng-init="content='first'">       <br />       <label for="other">show other content</label>       <input id="other" type="radio" name="content" ng-model="content" value="other">     </form>      <div class="wrapper">       <p ng-show="content == 'first'">this first content!</p>       <h2 ng-show="content == 'other'">this other content!</h2>     </div>   </div> </div> 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -