16 lines
1.8 KiB
HTML
Executable file
16 lines
1.8 KiB
HTML
Executable file
<a href="http://github.com/angular/angular.js/edit/master/docs/content/error/compile/selmulti.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">Binding to Multiple Attribute</code>
|
|
<div><span class="hint">error in component <code ng:non-bindable="">$compile</code>
|
|
</span>
|
|
</div>
|
|
</h1>
|
|
<div><pre class="minerr-errmsg" error-display="Binding to the 'multiple' attribute is not supported. Element: {0}">Binding to the 'multiple' attribute is not supported. Element: {0}</pre>
|
|
<h2 id="Description">Description</h2>
|
|
<div class="description"><div class="-compile-page -compile-selmulti-page"><p>Binding to the <code>multiple</code> attribute of <code>select</code> element is not supported since switching between multiple and single mode changes the <a href="api/ng.directive:ngModel"><code><code>ngModel</code></code></a> object type from instance to array of instances which breaks the model semantics.</p>
|
|
<p>If you need to use different types of <code>select</code> elements in your template based on some variable, please use <a href="api/ng.directive:ngIf"><code>ngIf</code></a> or <a href="api/ng.directive:ngSwitch"><code>ngSwitch</code></a> directives to select one of them to be used at runtime.</p>
|
|
<p>Example with invalid usage:</p>
|
|
<pre><code><select ng-model="some.model" multiple="{{mode}}"></select></code></pre>
|
|
<p>Example that uses ngIf to pick one of the <code>select</code> elements based on a variable:</p>
|
|
<pre><code><select ng-if="mode == 'multiple'" ng-model="some.model" multiple></select>
|
|
<select ng-if="mode != 'multiple'" ng-model="some.model"></select></code></pre>
|
|
</div></div>
|
|
</div>
|