Tuesday, January 30, 2018

How to write a program for select box in angularJS.

  • If you want to create a dropdown list, based on an object or an array in AngularJS, you should use the ng-options directive:

Program
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
</head>
<body>
<div ng-app="Abc" ng-controller="def">
<select>
<option ng-repeat="x in names"> {{x}}
</option>
</select>
</div>
<script>
var app = angular.module('Abc', []);
app.controller('def', function($scope)
{
    $scope.names = ["JavaScript", "PHP", "JAVA"];
});
</script>
</body>
</html>

Output




0 comments:

Post a Comment

Thanks For Commented.

TechTalk