mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
20 lines
927 B
Text
20 lines
927 B
Text
@ngdoc error
|
|
@name $compile:selmulti
|
|
@fullName Binding to Multiple Attribute
|
|
@description
|
|
|
|
Binding to the `multiple` attribute of `select` element is not supported since switching between multiple and single mode changes the {@link api/ng.directive:ngModel `ngModel`} object type from instance to array of instances which breaks the model semantics.
|
|
|
|
If you need to use different types of `select` elements in your template based on some variable, please use {@link api/ng.directive:ngIf ngIf} or {@link api/ng.directive:ngSwitch ngSwitch} directives to select one of them to be used at runtime.
|
|
|
|
|
|
Example with invalid usage:
|
|
```
|
|
<select ng-model="some.model" multiple="{{mode}}"></select>
|
|
```
|
|
|
|
Example that uses ngIf to pick one of the `select` elements based on a variable:
|
|
```
|
|
<select ng-if="mode == 'multiple'" ng-model="some.model" multiple></select>
|
|
<select ng-if="mode != 'multiple'" ng-model="some.model"></select>
|
|
```
|