Skip to content

Commit dbd703a

Browse files
mheveryIgorMinar
authored andcommitted
docs(compile/selmulti): description for compile/selmulti error
Closes angular#3459
1 parent fa39857 commit dbd703a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/content/error/compile/selmulti.ngdoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,19 @@
22
@name $compile:selmulti
33
@fullName Binding to Multiple Attribute
44
@description
5+
6+
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.
7+
8+
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.
9+
10+
11+
Example with invalid usage:
12+
```
13+
<select ng-model="some.model" multiple="{{mode}}"></select>
14+
```
15+
16+
Example that uses ngIf to pick one of the `select` elements based on a variable:
17+
```
18+
<select ng-if="mode == 'multiple'" ng-model="some.model" multiple></select>
19+
<select ng-if="mode != 'multiple'" ng-model="some.model"></select>
20+
```

src/ng/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ function $CompileProvider($provide) {
12911291

12921292

12931293
if (name === "multiple" && nodeName_(node) === "SELECT") {
1294-
throw $compileMinErr("selmulti", "Binding to the multiple attribute is not supported. Element: {0}",
1294+
throw $compileMinErr("selmulti", "Binding to the 'multiple' attribute is not supported. Element: {0}",
12951295
startingTag(node));
12961296
}
12971297

test/ng/directive/booleanAttrsSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('boolean attr directives', function() {
9393

9494
expect(function() {
9595
$compile('<select multiple="{{isMultiple}}"></select>')
96-
}).toThrow('[$compile:selmulti] Binding to the multiple attribute is not supported. ' +
96+
}).toThrow('[$compile:selmulti] Binding to the \'multiple\' attribute is not supported. ' +
9797
'Element: <select multiple="{{isMultiple}}">');
9898

9999
}));

0 commit comments

Comments
 (0)