P Jagajit Prusty P Jagajit Prusty - 4 months ago 216x
AngularJS Question

md-chips with md-select in multi select mode

When I am trying to generate md-chips on selecting multiple values from md-select, It is not working. Does md-chips works only with autocomplete analyser and input field?

<md-chips ng-model="launchAPIQueryParams.type">
<md-select name="launchCalType" ng-model="launchAPIQueryParams.type"
multiple="true" placeholder="Launch Type"
<md-option ng-repeat="typeOption in launchTypeOptions" ng-value="typeOption[1]">


The short answer: No. <md-chips> component will only takes <input> or <md-autocomplete> into its transcluded context.

However, the same thing can be achieved with md-autocompelet. The key is set md-min-length on <md-autocomplete> to 0 so it will auto show the menu just like what a <md-select> menu would be. Here's an example:

// controller.js
  .moduel('mdChipsDemo', [])
  .controller('MdChipsDemoCtrl', function() {
    var vm = this;
    vm.selectedOption = '';
    vm.searchText = '';
    vm.launchAPIQueryParams = {
        types: [],

    vm.launchTypeOptions = [
        {name: 'Op1', value: 1},
        {name: 'Op2', value: 2},
        {name: 'Op3', value: 3},
        {name: 'Op4', value: 4},

// template.html
<div ng-app="mdChipsDemo" ng-controller="MdChipsDemoCtrl as vm">
<md-chips ng-model="vm.launchAPIQueryParams.types">
            md-items="typeOption in vm.launchTypeOptions"
            placeholder="Search for a launchTypeOptions">
      <span md-highlight-text="vm.searchText">{{typeOption.name}}</span>

If your ultimate goal is to have multiple select ability, <md-autocomplete> also expose <md-item-template> where you can put your <md-select> in. Check the doc for md-autocomplete and you will see.

Or if you really insist on using <select>, there's an 3rd-party component on npm calls md-chips-select which does what you want. https://www.npmjs.com/package/md-chips-select