Ng-Init-6

 

In this example, We will show or hide the text based on the value of variable radioOption assigned to ng-show directive, this variable is being set in ng-init like ng-init="radioOption='true'" and after the user change the radio selection the text will be show/hide.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app> <div> <div ng-init="radioOption='true'"> <input type="radio" name="radioOption" ng-model="radioOption" value='true'>Show <input type="radio" name="radioOption" ng-model="radioOption" value='false'>Hide <br /> <div ng-show="radioOption=='true'" style="padding:10px; border:1px solid black; width:30%; font-weight:bold">Hi Welcome to LearnIt... Hello World</div> </div> </div> </body> </html>
Output