简体   繁体   中英

multiple attribute in angular-strap directives

I am using angular-strap's select . I have $scope.id in my controller and I want to set multiple attribute to true only when $scope.id is null. So, my code is:

<button type="button" class="btn btn-default full-width" ng-model="languages"
    data-html="1" multiple="{{!id}}" data-animation="am-flip-x" data-max-length="100" placeholder="Choose..."
    data-ng-options="language.Id as language.FriendlyName for language in languages" bs-select>
Action <span class="caret"></span>

But it doesn't work: in all cases the select is in multiple mode. I've tried other variants that didn't help me too, in all cases the select allows multiple selections:

multiple="{{id}}", data-ng-attr-multiple="!id, data-ng-attr-multiple="{{!id}}

And even

multiple="0", multiple="false"

It seems multiple attribute is used only for setting multiple mode...

Any ideas?

It is possible that the value of multiple attribute is only read once on initialization (need to check sources to verifiy it). You can always create two components and show them appropriately:

<button ng-if="id" type="button" ng-model="languages" ... bs-select>
<button ng-if="!id" type="button" ng-model="languages" ... bs-select multiple="true">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM