leocaseiro / angular-chosen

AngularJS Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a AngularJS way
http://leocaseiro.github.io/angular-chosen/
MIT License
682 stars 248 forks source link

'data-placeholder' does not work after adding ng-options #205

Closed pranjal-goswami closed 8 years ago

pranjal-goswami commented 8 years ago

Chosen version : 1.6.1 angular-chosen : 1.4.0

<select class="" chosen="{width:'100%'}" multiple data-placeholder="Recepients" ng-model="recepients">

The 'data-placeholder' attribute works fine as long as ng-options is not added

<select class="" chosen="{width:'100%'}" multiple data-placeholder="Recepients" ng-model="recepients" ng-options="contact as contact.name for contact in contactBook">

leocaseiro commented 8 years ago

Hi @pranjal-goswami, thank you for using the directive and for openning an issue.

You must use the attributes: placeholder-text-multiple and placeholder-text-single instead.

Please check the example

<select class="" chosen="{width:'100%'}" multiple placeholder-text-multiple="'Recepients'"
ng-model="recepients" ng-options="contact as contact.name for contact in contactBook">
</select>
pranjal-goswami commented 8 years ago

Hi @leocaseiro, thank you for your response. I tried using the suggested attribute but it did not work. I have made this jsFiddle for your perusal

leocaseiro commented 8 years ago

Hi @pranjal-goswami, I'm sorry, I actually forgot to mention that both placeholder-text-multiple and placeholder-text-single are expecting a bindable value, so you must use a string value or a variable:

<select class="" chosen="{width:'100%'}" multiple placeholder-text-multiple="'Recepients'"
ng-model="recepients" ng-options="contact as contact.name for contact in contactBook">
</select>

Or dynamic:

$scope.label = 'Recepients';
<select class="" chosen="{width:'100%'}" multiple placeholder-text-multiple="label"
ng-model="recepients" ng-options="contact as contact.name for contact in contactBook">
</select>

jsfiddle updated with both examples: https://jsfiddle.net/9d8n4zsf/

pranjal-goswami commented 8 years ago

Thanks a lot!