<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> <body ng-app=""> <form> Pick a topic: <input type="radio" ng-model="myVar" value="dogs">Workingcode <input type="radio" ng-model="myVar" value="tuts">ServiceNow <input type="radio" ng-model="myVar" value="cars">Angular </form> <div ng-switch="myVar"> <div ng-switch-when="dogs"> <h1>Workingcode.in</h1> <p>Welcome to Working Code</p> </div> <div ng-switch-when="tuts"> <h1>ServiceNow</h1> <p>Welcome to Working Code</p> </div> <div ng-switch-when="cars"> <h1>Angular</h1> <p>Welcome to Angular</p> </div> </div> <p>The ng-switch directive hides and shows HTML sections depending on the value of the radio buttons.</p> </body> </html>
Output:
Bind radio buttons to your application with the ng-model directive Angular JS
Working Code Asked question September 21, 2023