docs(compile/selmulti): description for compile/selmulti error

Closes #3459
This commit is contained in:
Misko Hevery 2013-08-01 15:53:59 -07:00 committed by Igor Minar
parent fa3985764c
commit dbd703a9fb
3 changed files with 18 additions and 2 deletions

View file

@ -2,3 +2,19 @@
@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>
```

View file

@ -1291,7 +1291,7 @@ function $CompileProvider($provide) {
if (name === "multiple" && nodeName_(node) === "SELECT") {
throw $compileMinErr("selmulti", "Binding to the multiple attribute is not supported. Element: {0}",
throw $compileMinErr("selmulti", "Binding to the 'multiple' attribute is not supported. Element: {0}",
startingTag(node));
}

View file

@ -93,7 +93,7 @@ describe('boolean attr directives', function() {
expect(function() {
$compile('<select multiple="{{isMultiple}}"></select>')
}).toThrow('[$compile:selmulti] Binding to the multiple attribute is not supported. ' +
}).toThrow('[$compile:selmulti] Binding to the \'multiple\' attribute is not supported. ' +
'Element: <select multiple="{{isMultiple}}">');
}));