August 23, 2016 21:54 by
Peter
In this post, i will tell you about ng ng-options instance but remove the selected items from previous uses in Angularjs. Now write the following code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="Scripts/angular.js"></script>
<link href="Content/bootstrap.css" rel="stylesheet" />
<script>
var app = angular.module('myApp', []);
app.controller('demoCtrl', function ($scope)
{
$scope.options = [
{
name: 'Apple',
id: '1'
},
{
name: 'Orange',
id: '2'
},
{
name: 'Banana',
id: '3'
},
{
name: 'Pear',
id: '4'
}, ];
});
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="demoCtrl">
<div class="form-group col-md-3">
<label for="select1">Select 1:</label>
<select ng-model="newForm.select1" ng-options="option.name as option.name for option in options" class="form-control">
<option value=""></option>
</select>
</div>
<div class="row">
<br> </div>
<div class="form-group col-md-3">
<label for="select2">Select 2:</label>
<select ng-model="newForm.select2" ng-options="option.name as option.name for option in options | filter: newForm.select1 && {name: '!' + newForm.select1}" class="form-control">
<option value=""></option>
</select>
</div>
</div>
</body>
</html>
HostForLIFE.eu AngularJS Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.