Podcast/lib/angular/docs/partials/error/$compile:selmulti.html
2013-08-21 19:46:51 +02:00

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>&lt;select ng-model=&quot;some.model&quot; multiple=&quot;{{mode}}&quot;&gt;&lt;/select&gt;</code></pre>
<p>Example that uses ngIf to pick one of the <code>select</code> elements based on a variable:</p>
<pre><code>&lt;select ng-if=&quot;mode == &#39;multiple&#39;&quot; ng-model=&quot;some.model&quot; multiple&gt;&lt;/select&gt;
&lt;select ng-if=&quot;mode != &#39;multiple&#39;&quot; ng-model=&quot;some.model&quot;&gt;&lt;/select&gt;</code></pre>
</div></div>
</div>