axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

angular >1.4 requires select controller for ngoptions to work #9

Closed alzalabany closed 9 years ago

alzalabany commented 9 years ago

Example from readme.md

<div custom-select="asyncOptions" ng-model="custom2" ng-options="a for a in async">
    <div class="pull-left" style="width: 40px"><img ng-src="{{t.picture}}" style="width: 30px" /></div>
    <div class="pull-left">
        <strong>{{t.name}}</strong><br />
        <span>{{t.phone}}</span>
    </div>
    <div class="clearfix"></div>
</div>

will produce error on version 1.4 and above since ngoptions requires select controller

Controller 'select', required by directive 'ngOptions', can't be found!
alzalabany commented 9 years ago

a quick fix would be to change ng-options to anything else in both your template and inside customeSelect.js

example

<div custom-select="asyncOptions" ng-model="custom2" cus-options="a for a in async">
    <div class="pull-left" style="width: 40px"><img ng-src="{{t.picture}}" style="width: 30px" /></div>
    <div class="pull-left">
        <strong>{{t.name}}</strong><br />
        <span>{{t.phone}}</span>
    </div>
    <div class="clearfix"></div>
</div>

Then search and replace attrs.ngOptions with atts.cusOptions

axel-zarate commented 9 years ago

I initially re-used the ng-options attribute to make the directive more familiar but didn't anticipate it would cause trouble down the road. In order to avoid introducing breaking changes, I added a cs-options attribute as an alternative to ng-options in this commit. Thank you for pointing out this issue.