Create select with data-ng-options

Description

The following code shows how to Create select with data-ng-options.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
<!-- w w w . j  a  v a  2  s.  c o m-->
var module = angular.module("example", []);

module.controller("orderByController", function ($scope) {
    $scope.orderByValue = function (value) {
        return value;
    };

    $scope.items = ["c", "b", "a"];
    $scope.item = "b";
});
</script>
</head>
<body>
  <div data-ng-app="example">
    <div data-ng-controller="orderByController">
        <select data-ng-model="item" data-ng-options="item for item in items | orderBy:orderByValue">
        </select>
    </div>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities