AngularJS Dropdown Multiselect -- Search Custom template per option.
I have found the solution of my query will be using the above url of the documentation of AngularJS Dropdown Multiselect but if I am using the below code, it doesn't reflect on the view of my application:
$scope.example19settings = {
    template: '<b>{{option.name}}</b>'
};
I want to acheive it by adding a count:
$scope.example19settings = {
    template: '<b>{{option.name}}({{option.count}})</b>'
};
Any suggestions or missing links?
$scope.extraSettings = {
    settings: {
        selectedToTop: true,
        styleActive: true,
        /*template: '<b>{{option.label}}</b>'*/
        scrollable: true,
        scrollableHeight: 200,
        showEnableSearchButton: true        
    }
};
                Please find working solution below. Following are the changes I have done.
Change the reference if miltiselect library to this (latest)
Added the 'angularjs-dropdown-multiselect' as dependency to my main app module
MainCtrl, assigned it to the template$scope.example19model = [];) to $scope for holding selected options.Let me know, if this works for you :)
var app = angular.module('app', ['angularjs-dropdown-multiselect']);
app.controller('MainCtrl', function($scope) {
  $scope.example19model = [];
  $scope.example19data = [{
    id: 1,
    name: "David",
    count: 20
  }, {
    id: 2,
    name: "Jhon",
    count: 30
  }, {
    id: 3,
    name: "Lisa",
    count: 40
  }, {
    id: 4,
    name: "Nicole",
    count: 50
  }, {
    id: 5,
    name: "Danny",
    count: 60
  }];
  $scope.example19settings = {
    template: '<b>{{option.name}} ({{option.count}})</b>'
  };
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.js"></script>
<script src="https://rawgit.com/dotansimha/angularjs-dropdown-multiselect/master/dist/angularjs-dropdown-multiselect.min.js"></script>
<div ng-app="app">
  <div ng-controller="MainCtrl">
    <div ng-dropdown-multiselect="" options="example19data" selected-model="example19model" extra-settings="example19settings"></div>
    {{example19model}}
  </div>
</div>
You can use select2 library which helps to select multiple inputs.
Check this link for live demo.
<h3>Array of strings</h3>
  <ui-select multiple ng-model="ctrl.multipleDemo.colors" theme="bootstrap" ng-disabled="ctrl.disabled" close-on-select="false" style="width: 300px;" title="Choose a color">
    <ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
    <ui-select-choices repeat="color in ctrl.availableColors | filter:$select.search">
      {{color}}
    </ui-select-choices>
  </ui-select>
  <p>Selected: {{ctrl.multipleDemo.colors}}</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With