Tuesday, January 30, 2018

How to write a program for forms in angularJS.

  • Input controls are the HTML input elements:

  1. input elements
  2. select elements
  3. button elements
  4. textarea elements
  • We are using a button elements in this example.
  1. Bind radio buttons to your application with the ng-model directive.
  2. Radio buttons with the same ng-model can have different values, but only the selected one will be used.
Program
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
</head>
<body ng-app="">
<form>
Pick topic:
<input type="radio" ng-model="ABC" value="Animals">Animals
<input type="radio" ng-model="ABC" value="Cars">Cars
<input type="radio" ng-model="ABC" value="Flowers">Flowers
</form>
<div ng-switch="ABC">
<div ng-switch-when="Animals">
<h1> Animals</h1>
<p>Wlcome to world of Animals</p>
</div>
<div ng-switch-when="Cars">
<h1> Cars</h1>
<p>Wlcome to worls of Cars</p>
</div>
<div ng-switch-when="Flowers">
<h1> Flowers</h1>
<p>Wlcome to worls of Flowers</p>
</div>
</div>
</body>
</html>

Output



0 comments:

Post a Comment

Thanks For Commented.

TechTalk