Bind select to scope

Description

The following code shows how to Bind select to scope.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
'use strict';<!-- ww  w  .  j av a 2  s . c  o m-->
var app = angular.module('myApp', []);
function FooListCtrl($scope) {
    $scope.foos = {"Bar": [ "foo", "bar"]};
    $scope.selected = [];
}
</script>
</head>
<body>
  <body ng-app="myApp" ng-controller="FooListCtrl">
  <span ng-repeat="foolist in foos">
    <select ng-model="selected" ng-options="foo for foo in foolist" multiple="multiple">
    </select>
      {{selected}}
  </span>
  {{selected}}
</body>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities