-1

I have a queation to AngularJS Guru. Is it possibile to remove blank value from next listing where klassList is some list of objects. I need exactly ng-repeat and not ng-options [{"id":1,"klassName":"11A","pupils":null},{"id":2,"klassName":"12B","pupils":null}] :

<input type="text" class="form-control" ng-model="klassName1"/>
<select class="form-control" ng-model="selectedItem" >
    <option ng-repeat="klass in klassList | filter :  {klassName : klassName1}">{{klass.klassName}}</option>
</select>

My target is to obtain dropdown list with possibility of filtering values.

Pavel Vornic
  • 35
  • 1
  • 8

1 Answers1

0

Use ng-options

ng-options="givendata as givendata .klassName for givendata in klassList"

angular.module('app', []).controller('SelectorCtrl', function($scope) {
  $scope.klassList  = [{"id":1,"klassName":"11A","pupils":null},{"id":2,"klassName":"12B","pupils":null}];
});
<!DOCTYPE html>
<html ng-app="app">
<head>
  <script data-require="angular.js@1.4.3" data-semver="1.4.3" src="https://code.angularjs.org/1.4.3/angular.js"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>
<body ng-controller="SelectorCtrl">
  <h1>Hello!</h1>
  <select class="form-control"  ng-model="selectedItem" id="state" ng-model="divisionsSource" ng-options="givendata  as givendata.klassName for givendata in klassList">
    <option value=''>Select</option>
  </select>
  
</body>
</html>
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396